microsoft / microsoft/knack

How to disable default Global Arguments (especially -o)?

Open
#246 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
358
Forks
101
PR merge metrics
No merged PRs in 30d

Description

I have a command accepting argument --output-path, and I set its options_list also accept "-o", but it does not work, conflict with the default global argument. It means we can't use --output and -o for our commands.

Question:

  1. How to disable Global Arguments, at least for "--output", "-o", or even "--query"?

More details:
with ArgumentsContext(self, "config fetch") as arg_context:
arg_context.argument("output", type=str, options_list=("-o", "--output-path"))

When I tried it, it reports conflict error:
$ mycli config fetch -o test.json
argument -o/--output-path: conflicting option string: -o

and only this option works:
$ mycli config fetch --output-path test.json

$ mycli config fetch -h

Command
mycli config fetch

Arguments
--output-path : Default: my_config.json.

Global Arguments
--debug : Increase logging verbosity to show all debug logs.
--help -h : Show this help message and exit.
--only-show-errors : Only show errors, suppressing warnings.
--output -o : Output format. Allowed values: json, jsonc, none, table, tsv, yaml, yamlc.
Default: json.
--query : JMESPath query string. See http://jmespath.org/ for more information and
examples.
--verbose : Increase logging verbosity. Use --debug for full debug logs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ArgumentsContext usage shown in the issue and trace how global arguments are registered alongside command-specific options_list entries. Determine whether disabling or overriding --output/-o and --query is supported, then document the supported behavior and verify it against the shown config fetch command and conflict error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.