Skip to content

Conversation

@bitwes
Copy link
Owner

@bitwes bitwes commented Jun 10, 2024

I wanted a better optparse to use in other places so I beefed up the one GUT uses. If you need to parse command line options you can copy addons/gut/cli/optparse.gd. It has no dependencies in GUT. See scratch/optparse_example.gd for some usage examples.

Changes for GUT

  • options that take a value can now be specified with a space (option value) instead of using option=value.
  • -gh option now has headings for the different options. It looks a lot better.
  • -gdir and -gtest can be specified multiple times instead of using a comma delimited list.

Changes to optparse.gd

  • A giant amount of documentation added to the top of optparse.gd. Read that for full info about usage.
  • Supports headings to group like options together.
  • Supports positional options.
  • Parses values that follow an option. Using option=value is now an optional way to specify an option value.
  • Empty array values can now be specified with option=. Before you would always get [''] as the value.
  • Generates "Usage" section in the help.
  • Boolean options can default to true and will be set to false if specified.
  • Looks like I forgot to test optparse.gd originally, it now has a full set of tests.
  • Array values are appended if specified multiple times.
@bitwes bitwes merged commit f5dd27a into main Jun 11, 2024
@bitwes bitwes deleted the optparse_v2 branch June 11, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants