Re: [BuildStream] bst CLI design and consistency (UI)



On Thu, Dec 06, 2018 at 06:50:49PM +0100, Jürg Billeter wrote:
Hi Richard,

On Thu, 2018-12-06 at 17:28 +0000, Richard Maw via BuildStream-list
wrote:
Click not only has no built-in support for this
but obstructs us in attempting to do our own parsing
by consuming the -- itself and having no facility for us to get it.

    $ cat > test.py <<'EOF'
    > import click
    > 
    > @click.command()
    > @click.argument('args', nargs=-1)
    > def main(args):
    >     print(args)
    > 
    > if __name__ == '__main__':
    >     main()
    > EOF
    $ python3 test.py foo bar -- baz qux
    foo bar baz qux

We could disable `allow_interspersed_args` as I don't think we
need/want that anyway:

      import click

      @click.command(context_settings={"allow_interspersed_args": False})
      @click.argument('args', nargs=-1)
      def main(args):
          print(args)

      if __name__ == '__main__':
          main()

      $ python3 test.py foo bar -- baz qux
      ('foo', 'bar', '--', 'baz', 'qux')

That's interesting.

I looked at allow_interspersed_args when I started,
though I can't remember why I dismissed the idea.

I can see a heuristic still being wanted,
though using -- has always been good practice for the subcommand
so there shouldn't be too many complaints about it now behaving differently.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]