metaschema-framework / oscal-cli

https://oscal-cli.metaschema.dev/
Other
3 stars 4 forks source link

Help Output is Incorrect for Validate #80

Open brian-ruf opened 1 week ago

brian-ruf commented 1 week ago

Describe the bug

The help output from oscal-cli for validate incorrectly shows the options before the source file.

Who is the bug affecting

Users attempting to validate content, using the help output from oscal-cli

How do we replicate this issue

  1. Run oscal-cli validate --help (or attempt to use the validate command without correct input)
  2. Observe first line of output: usage: oscal-cli validate [<options>] <file-or-URI-to-validate>

Shows [<options>] before file-or-URI-to-validate

Expected behavior (i.e. solution)

This should present: usage: oscal-cli validate <file-or-URI-to-validate> [<options>]

Other comments

The syntax here is correct: [usage: oscal-cli validate [] ](usage: oscal-cli validate [] )

david-waltermire commented 3 days ago

The current output oscal-cli validate [<options>] <file-or-URI-to-validate> is intentional and consistent across all commands. The current approach mirrors what is a common pattern in most *nix commands, for which the CLI was modeled after.

For example, apt:

Usage: apt [options] command

Or grep:

Usage: grep [OPTION]... PATTERNS [FILE]...

A somewhat counter example with before and after, git:

usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--config-env=<name>=<envvar>] <command> [<args>]

In reality, options can come before or after the extra arguments, so you can make an argument that either or both are correct.

Given that this is a stylistic issue that is subject to personal taste, it would be informative to see if others weight in on this change before making any adjustments. For now, its probably best to leave it as-is.