mirror of
https://github.com/ansible/awx.git
synced 2026-02-21 13:10:11 -03:30
Merge pull request #4854 from ryanpetrello/cli-login-formatting
cli: make `awx login` respect the -f flag Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -17,7 +17,7 @@ The preferred mechanism for authenticating with AWX and |RHAT| is by generating
|
|||||||
TOWER_PASSWORD=secret \
|
TOWER_PASSWORD=secret \
|
||||||
awx login
|
awx login
|
||||||
|
|
||||||
As a convenience, the ``awx login`` command prints a shell-formatted token
|
As a convenience, the ``awx login -h human`` command prints a shell-formatted token
|
||||||
value:
|
value:
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
@@ -30,7 +30,7 @@ specify your username and password each time:
|
|||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
export TOWER_HOST=https://awx.example.org
|
export TOWER_HOST=https://awx.example.org
|
||||||
$(TOWER_USERNAME=alice TOWER_PASSWORD=secret awx login)
|
$(TOWER_USERNAME=alice TOWER_PASSWORD=secret awx login -h)
|
||||||
awx config
|
awx config
|
||||||
|
|
||||||
Working with OAuth2.0 Applications
|
Working with OAuth2.0 Applications
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import os
|
|||||||
from six import PY3, with_metaclass
|
from six import PY3, with_metaclass
|
||||||
|
|
||||||
from awxkit import api, config
|
from awxkit import api, config
|
||||||
|
from awxkit.utils import to_str
|
||||||
from awxkit.api.pages import Page
|
from awxkit.api.pages import Page
|
||||||
from awxkit.cli.format import format_response, add_authentication_arguments
|
from awxkit.cli.format import FORMATTERS, format_response, add_authentication_arguments
|
||||||
from awxkit.cli.utils import CustomRegistryMeta, cprint
|
from awxkit.cli.utils import CustomRegistryMeta, cprint
|
||||||
|
|
||||||
|
|
||||||
@@ -98,7 +99,11 @@ class Login(CustomCommand):
|
|||||||
'red'
|
'red'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
print('export TOWER_TOKEN={}'.format(token))
|
fmt = client.get_config('format')
|
||||||
|
if fmt == 'human':
|
||||||
|
print('export TOWER_TOKEN={}'.format(token))
|
||||||
|
else:
|
||||||
|
print(to_str(FORMATTERS[fmt]({'token': token}, '.')).strip())
|
||||||
|
|
||||||
|
|
||||||
class Config(CustomCommand):
|
class Config(CustomCommand):
|
||||||
|
|||||||
Reference in New Issue
Block a user