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



Hi Richard,

On Thu, 2018-12-06 at 17:28 +0000, Richard Maw via BuildStream-list
wrote:
On Wed, Dec 05, 2018 at 11:14:57AM +0100, Jürg Billeter wrote:
I'd like to avoid the need for `--command`. Command wrappers on UNIX
systems typically use `--` as separator where that's necessary. Is
there no way with `Click` we can support `--` between element arguments
and command?

If `Click` has no built-in support for this, can't we do it ourselves,
i.e., declare a single `Click` argument list for both? I don't know
whether we can provide proper help/usage in that case, but worst case
we could still explain usage in the help text for that combined option.
And with mandatory .bst extensions, we could even make `--` optional.

I looked at doing this before settling on the `-e` syntax.

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')

Cheers,
Jürg



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