qooxdoo / qooxdoo

qooxdoo - Universal JavaScript Framework
http://qooxdoo.org
Other
765 stars 261 forks source link

Qooxdoo CLI args #10376

Open rad-pat opened 2 years ago

rad-pat commented 2 years ago

Re-use of CLI args and/or aliases is causing ugly output in CLI help, e.g. output of qx lint --help is There are multiple entries for -F, -c, -v & -q

qx lint [files...]

runs eslint on the current application or as set of single files.

Options:
  --force, -F, -F        Override warnings            [boolean] [default: false]
  --config-file, -c, -c  Specify the config file to use                 [string]
  --verbose, -v, -v, -v  enables additional progress output to console
                                                      [boolean] [default: false]
  --debug                enables debug output         [boolean] [default: false]
  --quiet, -q, -q, -q    No output                                     [boolean]
  --colorize             colorize log output to the console using ANSI color
                         codes                         [boolean] [default: true]
  --version              Show version number                           [boolean]
  --help                 Show help                                     [boolean]
  --set                  sets an environment value for the compiler      [array]
  --set-env              sets an environment value for the application   [array]
  --fix                  runs eslint with --fix
  --fix-jsdoc-params     changes the order or @param name and {Type} to make it
                         compatible for the generator ('name-first') or with
                         JSDoc linting ('type-first').
                   [choices: "off", "name-first", "type-first"] [default: "off"]
  --use-eslintrc         Use the .eslintrc file for configuration, if it exists
                                                       [boolean] [default: true]
  --cache                operate only on changed files[boolean] [default: false]
  --warnAsError, -w      handle warnings as error
  --print-config, -p     print the eslint configuration
  --format, -f           use a specific output format     [default: "codeframe"]
  --outputFile, -o       specify file to which the report will be written
                                                                        [string]
hkollmann commented 2 years ago

Any idea how to solve this?

johnspackman commented 2 years ago

Ditch yargs. I have a replacement, I'll try and get it out later this week

johnspackman commented 2 years ago

The CLI code is available here: https://github.com/johnspackman/zen-cms/tree/master/source/class/zx/cli

cboulanger commented 2 years ago

Cool, a native qooxdoo cli manager! Getting rid of a dependency would be nice but it might be quite a bit of work to replace Yargs

johnspackman commented 2 years ago

I suspect that a compatibility API could be scrubbed together to make the existing yargs configuration translate. There are things that yargs cannot do (and i've tried a few others before giving up and rolling my own in exasperation) that this will, mostly to do with subcommands and a recursive-descent style parser. Bash completion is straightforward but not implemented.

The best reason for replacing yargs though is that this code has a route to allow dynamically determined sub commands, executed from packages. Ultimately, i plan on releasing this zen-cms to qooxdoo and I'm thinking about proposing that instead of ./zx somecommand there is qx zen somecommand

hkollmann commented 1 year ago

@johnspackman : Is it allowed to miove your cli interface to qooxdoo kernel? I found some more issues with yargs, e,g, the run handler is called during args processing. So the order of async calls are sometime unpredictible.

johnspackman commented 1 year ago

@hkollmann yes, definitely. Yargs is a pain, and I quite like the design in that repo

I am so overrun with work that the CMS project is constantly on the back burner, and when it is complete I'll be offering it back to the Qoxodoo community anyway. By all means pull it into the core.

hkollmann commented 1 year ago

@johnspackman : Could you please explain the difference between argument and flag?

johnspackman commented 1 year ago

a flag is a value that is prefixed on the command line with a --name, or is just --name on its own and can occur in any sequence; but an argument is a positional value that does not have a name (on the command line).

For example in the zx license command, there is zx --dry-run --template=templatefile.js first-file.js second-file.js third-file.js. The --dry-run is a boolean flag, --template is a string flag, and first-file.js second-file.js third-file.js is a positional argument which is an array of strings.

Just realised how uncommented that code is, sorry :(