Open bdrelling opened 4 years ago
@bdrelling Thanks for identifying this issue and writing up the proposals! I definitely agree that this is a hole we need to address. I really like the hybrid help screen that you’ve put together in proposal 2 — it looks like it accurately describes what you’re able to do when calling the command, which is how I’d evaluate a solution.
Two notes/questions:
zinc sync --help
, just without showing the sync
subcommand. Does that sound right?(default)
note at the beginning of the sync
abstract?it looks like it accurately describes what you’re able to do when calling the command, which is how I’d evaluate a solution.
I agree this is a nice property.
- I think the first usage line would match that of
zinc sync --help
, just without showing thesync
subcommand. Does that sound right?
+1
- With proposal 2, would you still want to include the
(default)
note at the beginning of thesync
abstract?
+1
@natecook1000 thanks for the quick feedback!
I think the first usage line would match that of zinc sync --help, just without showing the sync subcommand. Does that sound right?
Agreed with that, yep!
With proposal 2, would you still want to include the (default) note at the beginning of the sync abstract?
Definitely! I'm editing the initial description to add this in there as well. I was initially treating this as two independent proposals because I wasn't sure if both would be valuable. I can merge them together if that's easier to track?
@bdrelling Makes sense!
Looks like this was addressed by #183.
Oh wait, only the (default)
tag was added there — the rest is still tbd. Re-opening!
@natecook1000 Hi, I was working on the second proposal and I got it somewhat working but I have some questions which I would like some help with.
Basically, my questions are:
@Argument
and default subcommand at the same depth?Below are description of the status of my implementaion.
Currently, math
command outputs help that looks like this with my changes.
In the USAGE, there are both math [--hex-output] [<values> ...]
for default add
subcommand and math <subcommand>
for the other subcommands. There is additional -x, --hex-output Use hexadecimal notation for the result.
for default add
subcommand in the OPTIONS
I also replicate zinc
command like this:
and zinc --help
outputs
However, if a user has nested default subcommands, the help text becomes a bit crazy with my current chanages. Given this command:
the help text when running super --help
becomes
and super sub --help
outputs
The USAGE lines are not useful because parsing does not work as expected. This might be an edge case that SAP does not support.
@natecook1000 Hi! I appreciate it if you could help me with my question above. Thank you in advance!
Commands with default subcommands do not have discoverable usage information without digging into the subcommand itself. Below, I'll outline the structure of a simple project as well as two proposals for updating the help information for commands that have a default subcommand.
Simply put, a command with a default subcommand likely doesn't have any information it runs itself and, as such, should specify the information that is available by running the default subcommand.
Structure
For ease of clarity, repeating the structure of my project here:
Command:
zinc
Subcommands:lint
,sync
Default Subcommand:sync
Proposal 1 - Highlighting the Default Subcommand
Problem Statement
The output of
zinc --help
is such that the default subcommand is not made clear.This is what prints:
Proposed Solution
I'm proposing we highlight the default subcommand somehow:
Proposal 2 - Prefer Default Subcommand Usage
Problem Statement
If I specify a default subcommand in my project, while I would allow someone to run
zinc sync <args>
, specifying a default subcommand likely implies that I'm happy withzinc <args>
. As such, I think that the output of<command> --help
should be refined.Right now, here's what prints out when I run
zinc --help
:Here is the output of
zinc sync --help
:Proposed Solution
I'm not sure what the right answer is here, but I imagine we should see an example of the default command being run, along with additional subcommands still.
I'm not sold on this, but here's an example:
Additional Notes
I'd like some additional feedback on the proposed solutions. I'm poking around at a variety of commands that I use day-to-day in my Swift projects as well as some outside of the Swift ecosystem and there's a variety of answers, but almost all at least provide some help documentation for a default subcommand within the help documentation of the command itself if requested.