rsm-hcd / AndcultureCode.Cli

and-cli command-line tool to manage the development of software applications
https://andculture.com
Apache License 2.0
14 stars 15 forks source link

Utility command for recursively listing commands & options #132

Closed brandongregoryscott closed 3 years ago

brandongregoryscott commented 3 years ago

It might be nice to have a command to output a list of all commands, sub-commands, and their options. I found myself doing this to make a checklist for the Typescript port to make sure I'm not missing anything, but it could be nice to have a little debugging command to spit out this info for the future.

Preferably, it would output in some sort of indented tree, similar to the tree command for listing directory structures.

This is what I ended up with (stripped out the command/option descriptions, but those could probably be included, or have the ability to exclude them)

- [ ] `copy`
    - [ ] `-d, --destination <destination>`
    - [ ] `-f, --flags <options>`
    - [ ] `-s, --source <source>`
- [ ] `deploy`
    - [ ] `aws-beanstalk`
        - [ ] `--dotnet`
        - [ ] `--timeout <timeout>`
        - [ ] `--verbose`
    - [ ] `aws-s3`
        - [ ] `--destination <destination>`
        - [ ] `--profile <profile>`
        - [ ] `--public-url <url>`
        - [ ] `--publish`
        - [ ] `--source <source>`
        - [ ] `--webpack`
    - [ ] `azure-storage`
        - [ ] `--client-id <clientID>`
        - [ ] `--destination <destination>`
        - [ ] `--public-url <url>`
        - [ ] `--publish`
        - [ ] `--recursive`
        - [ ] `--secret <profile>`
        - [ ] `--source <source>`
        - [ ] `--tenant-id <tenantID>`
        - [ ] `--username <username>`
        - [ ] `--webpack`
    - [ ] `azure-web-app`
        - [ ] `--app-name <applicationName>`
        - [ ] `--branch <branch>`
        - [ ] `--client-id <clientID>`
        - [ ] `--force`
        - [ ] `--remote <remote>`
        - [ ] `--resource-group <resourceGroup>`
        - [ ] `--secret <profile>`
        - [ ] `--tenant-id <tenantID>`
        - [ ] `--username <username>`
- [ ] `dotnet`
    - [ ] `-b, --build`
    - [ ] `-c, --clean`
    - [ ] `-C, --cli`
    - [ ] `-k, --kill`
    - [ ] `-p, --publish`
    - [ ] `-R, --restore`
    - [ ] `-r, --run`
    - [ ] `-w, --watch`
- [ ] `dotnet-test`
    - [ ] `--by-project`
    - [ ] `--ci`
    - [ ] `--coverage`
    - [ ] `-s, --skip-clean`
- [ ] `github`
    - [ ] `--add-topic <topic>`
    - [ ] `--list-repos`
    - [ ] `--list-topics`
    - [ ] `--remove-topic <topic>`
    - [ ] `-r, --repo <repo>`
    - [ ] `-u, --username <username>`
- [ ] `install`
- [ ] `migration`
    - [ ] `-a, --add`
    - [ ] `-d, --delete`
    - [ ] `-r, --run`
- [ ] `nuget`
    - [ ] `-p, --publish <version>`
    - [ ] `-u, --upgrade`
- [ ] `webpack`
    - [ ] `-c, --clean`
    - [ ] `-p, --publish`
    - [ ] `-R, --restore`
- [ ] `webpack-test`
    - [ ] `--ci`
    - [ ] `-c, --clean`
    - [ ] `-R, --restore`
- [ ] `workspace`
    - [ ] `-c, --clone`
    - [ ] `-f, --fork`
    - [ ] `-u, --usernames <usernames>`

This format allows for checkbox formatting in markdown, but the 'prefix' of the line could also be configurable.

brandongregoryscott commented 3 years ago

Started digging into this while building out a checklist for a recent PR. I think we will need to call the CLI itself to get the options for each command - because we've broken out each command into its own file, the top-level program doesn't know about any of the subcommand options. With the new Process.spawn method, this shouldn't be too hard - albeit a bit slow, running synchronously + recursively through child commands.

We may even be able to repurpose/extract the TestUtils.executeCliCommand which runs the async version of spawn and knows how to build the path to the compiled JS.

wintondeshong commented 3 years ago

Started digging into this while building out a checklist for a recent PR. I think we will need to call the CLI itself to get the options for each command - because we've broken out each command into its own file, the top-level program doesn't know about any of the subcommand options. With the new Process.spawn method, this shouldn't be too hard - albeit a bit slow, running synchronously + recursively through child commands.

We may even be able to repurpose/extract the TestUtils.executeCliCommand which runs the async version of spawn and knows how to build the path to the compiled JS.

Depending upon the performance, it could be worth making this command cache by default. Where when run it generates a dot file (or something) and unless a no-cache flag is provided to the command, it loads the file if the current version is the same as that of the cache file. Heck, could be a build artifact even

brandongregoryscott commented 3 years ago

Oo, I like it 👍 That's true - it probably won't be changing that much that you'd need it on demand all of the time.