Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added in CLI Argument Processing. #1626

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adamharrison
Copy link
Member

WIP.

@adamharrison adamharrison marked this pull request as draft September 25, 2023 13:39
@adamharrison
Copy link
Member Author

Anyway, thoughts behind this approach?

This basically allows you to specify command line flags on a per-plugin basis. Default implementation allows you to simply set config properties as if you're typing lua.

It's very simple, but fairly powerful. Has the advantage of consuming flags directly, meaning that there's no complicated system for managing anything, and we can still report on unconsumed flags.

There's some issues relating to which project you're in, as in order for plugins to consume flags and determine load order, we need to load the project module first; meaning that we have to be careful about how we specify things on the command line; anything that looks like a filepath, even if it's an argument to a string argument would cause us to load that particular project. But this is a somewhat core-level problem.

Obviously we should probably include stuff like --x and --y and --help and whatnot.

@jgmdev
Copy link
Member

jgmdev commented Sep 29, 2023

For reference I'm leaving this here as the approach taken on pragtical pragtical/pragtical#28 the API is documented on the PR using lua doc comments with some basic usage example provided. Some of the features it supports:

  • Default command that provides --help --version and can be manipulated by plugins to add more flags/functionality
  • Additional commands registration support (each command can have their own flags and subcommands)
  • Support specifying the max and min arguments supported by a command
  • Recursive subcommands support eg: app_binary command1 command2
  • Automatic flags type checking and error reporting
  • Flag types supported: empty, number, string, boolean, list
  • Automatic help generation for registered commands
  • Colorized help output
  • When a command is found on the args list the associated callback gets automatically executed receiving the found flags and arguments
  • Ability to specify if when a command is executed the editor should exit.
  • etc...

Some example of live plugin (editorconfig) PR adapted to optionally use the CLI API when available pragtical/plugins#4

@Guldoman Guldoman linked an issue Oct 24, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] CLI arguments
2 participants