Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to output token value without extra messages #7217

Merged
merged 2 commits into from
Nov 23, 2022

Conversation

amercader
Copy link
Member

When running ckan user token add you get this output by default:

API Token created:
        eyJ0eXAiOiJKV1QiL...

This is user-friendly, but is not great for integrating in automated scripts as you need to clean up the output a bit, eg:

export CKAN_API_TOKEN=$(ckan user token add ckan_user my_token | tail -n 1 | tr -d '\t')

Proposed fixes:

The changes suggested add a --quiet / -q flag that make the command just output the token directly so you can do:

export CKAN_API_TOKEN=$(ckan user token add ckan_user my_token -q)

Features:

  • includes bugfix for possible backport

When running `ckan user token add` you get this output by default:

```
API Token created:
        eyJ0eXAiOiJKV1QiL...
```

This is user-friendly but is not great for integrating in user scripts
as you need to clean up the output a bit, eg:

```
export CKAN_API_TOKEN=$(ckan user token add ckan_user my_token | tail -n 1 | tr -d '\t')
```

The changes suggested add a `--quiet` / `-q` flag that make the command
just output the token directly so you can do:

```
export CKAN_API_TOKEN=$(ckan user token add ckan_user my_token -q)
```
Copy link
Contributor

@kowh-ai kowh-ai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @amercader!!
Screenshot 2022-11-23 at 11 09 24 am

@kowh-ai kowh-ai merged commit bf92c85 into master Nov 23, 2022
@kowh-ai kowh-ai deleted the cli-user-token-create-quiet branch November 23, 2022 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants