Positional argument doesn't work after flag argument
Describe the bug https://github.com/AzureCR/azure-cli/issues/161
To Reproduce
az acr build -r MyRegistry --no-push .
az acr build: '.' is not an az acr build command. See 'az acr build --help'.
The following however works:
az acr build -r MyRegistry . --no-push
Expected behavior The CLI shouldn't take the positional argument as a value for flag argument.
Environment summary azure-cli (2.0.41)
acr (2.0.29) acs (2.1.3) advisor (0.5.3) ams (0.1.3) appservice (0.1.37) backup (1.1.3) batch (3.2.6) batchai (0.3.3) billing (0.1.10) cdn (0.1.0) cloud (2.0.16) cognitiveservices (0.1.15) configure (2.0.18) consumption (0.3.3) container (0.2.1) core (2.0.41) cosmosdb (0.1.23) dev-tools (0.1.1) dla (0.1.2) dls (0.1.0) dms (0.1.0) eventgrid (0.1.14) eventhubs (0.1.5) extension (0.1.1) feedback (2.1.4) find (0.2.12) interactive (0.3.24) iot (0.1.23) keyvault (2.0.24) lab (0.1.0) maps (0.2.0) monitor (0.1.9) network (2.1.6) nspkg (3.0.3) policyinsights (0.1.0) profile (2.0.28) rdbms (0.2.6) redis (0.2.15) reservations (0.2.2) resource (2.0.33) role (2.0.28) servicebus (0.1.4) servicefabric (0.1.0) sql (2.0.29) storage (2.0.37) testsdk (0.1.4) vm (2.0.36)
Python location 'C:\Users\doyou\gitrepo\azure-cli-venv\Scripts\python.exe' Extensions directory 'C:\Users\doyou.azure\cliextensions'
Python (Windows) 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)]
/cc @sajayantony @ankurkhemani
The reason you observe this behavior is because --no-push isn't a pure flag--you have it registered as three_state_flag which means it could have a value (true/false). Thus, it is parsing . against the allowed values of true/false.
This is standard argparse behavior so we would not make alterations to the CLI to change this; however, it looks like --no-push is a behavioral flag on the command, which means pure flag behavior (action='store_true') would be more appropriate than three state flag, which is really meant for boolean properties on resources. If that's the case, you can change it to a pure flag and you wouldn't see this issue.