Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add option to output token value without extra messages#7217

Merged
kowh-ai merged 2 commits into
masterfrom
cli-user-token-create-quiet
Nov 23, 2022
Merged

Add option to output token value without extra messages#7217
kowh-ai merged 2 commits into
masterfrom
cli-user-token-create-quiet

Conversation

@amercader
Copy link
Copy Markdown
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
Copy Markdown
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