Skip to content

Commit

Permalink
fix(cli): Add ability to escape at-prefixed parameter (python-gitlab#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pyhedgehog committed Mar 9, 2023
1 parent 7d779c8 commit dcd1d50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/cli-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@ command line. This is handy for values containing new lines for instance:
EOF
$ gitlab project create --name SuperProject --description @/tmp/description
It you want to explicitly pass argument starting with "@" - double it:

.. code-block:: console
$ gitlab project-tag list --project-id somenamespace/myproject
...
name: @at-started-tag
...
$ gitlab project-tag delete --project-id somenamespace/myproject --name '@@at-started-tag'
Enabling shell autocompletion
=============================

Expand Down
2 changes: 2 additions & 0 deletions gitlab/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ def _get_parser() -> argparse.ArgumentParser:


def _parse_value(v: Any) -> Any:
if isinstance(v, str) and v.startswith("@@"):
return v[1:]
if isinstance(v, str) and v.startswith("@"):
# If the user-provided value starts with @, we try to read the file
# path provided after @ as the real value. Exit on any error.
Expand Down

0 comments on commit dcd1d50

Please sign in to comment.