mozilla-services / mozilla-services/obs-common

create a listcommands command

Open
#41 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
1
Avg merge
13h 3m
Merged PRs (30d)
7

Description

I was thinking out loud in https://github.com/mozilla-services/antenna/pull/1100#issuecomment-2457261580 about why I wrote socorro-cmd, but don't generally like it and don't really want to carry it across to all the services we maintain.

That got me thinking that maybe instead of having a script runner we have a command that lists the available commands.

All of our commands are of one of two groups:

  1. installed with a Python package -- we can list these automatically because they're listed in the console_scripts entrypoint package metadata

    https://docs.python.org/3/library/importlib.metadata.html#importlib.metadata.entry_points

    >>> import importlib.metadata
    >>> [ep.name for ep in importlib.metadata.entry_points()["console_scripts"] if ep.value.startswith(("obs_common", "crashstats_tools", "honcho"))]
    ["honcho", "gcs_cli", "pubsub_cli", ...]
    
  2. located in the /app/bin directory

Given that, we can write a command that lists existing commands without having to manually maintain the list of commands.

Example usage:

> make shell
app> listcommands
Available commands:

honcho   gcs_cli   pubsub_cli  ...

See service developer documentation for more details.

Maybe it lists it by source?:

Example usage:

> make shell
app> listcommands
obs-common commands:

gcs_cli   pubsub_cli   waitfor   ...

crashstats-tools commands:

fetch_data   supersearch   reprocess   ...

/app/bin commands:

db   es   ...

See developer documentation for more details.

It could even be something we add to obs-common and note in our docs.

If we built this script in obs-common, then we maintain it in one place, it gets installed everywhere, and wouldn't have to do much to maintain it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed importlib.metadata console_scripts lookup and the commands available in /app/bin. Resolve whether the command belongs in obs-common and whether output should be grouped by source, then confirm that it lists installed commands and /app/bin commands without manual maintenance.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.