Skip to content

Commit

Permalink
feat: add non-interactive option for auth
Browse files Browse the repository at this point in the history
  • Loading branch information
adamtabrams authored Jan 12, 2021
1 parent 3fa61e5 commit 008a93c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.8.0] - 2021-01-11
### Added
- Added an option to provide a token for the auth command as another argument.

## [0.7.1] - 2021-01-07
### Fixed
- Use `--decode` arg with base64 to get proper behavior with BSD and GNU versions.
Expand Down Expand Up @@ -89,7 +93,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Created a proof of concept for a changelog updater.

[Unreleased]: https://github.com/adamtabrams/change/compare/0.7.1...HEAD
[Unreleased]: https://github.com/adamtabrams/change/compare/0.8.0...HEAD
[0.8.0]: https://github.com/adamtabrams/change/compare/0.7.1...0.8.0
[0.7.1]: https://github.com/adamtabrams/change/compare/0.7.0...0.7.1
[0.7.0]: https://github.com/adamtabrams/change/compare/0.6.1...0.7.0
[0.6.1]: https://github.com/adamtabrams/change/compare/0.6.0...0.6.1
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Then it tags the latest commit with that version and pushes the tag to origin.
#### Save a token with `change auth`
* This saves a personal access token for posting releases.
* Here are [instructions](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line#creating-a-token) for making one.
* Optionally, you can provide the token non-interactively: `change auth [TOKEN]`

#### Post a release to GitHub with `change post`
* This posts the section of the latest version in the changelog as a GitHub release.
Expand Down Expand Up @@ -58,4 +59,4 @@ This is the general workflow I use with this tool:
# Tips

With the help of curl, you can even run this tool without installing it:
* `curl -s "https://raw.githubusercontent.com/adamtabrams/change/master/change" | sh -s --` [args]
* `curl -s "https://raw.githubusercontent.com/adamtabrams/change/master/change" | sh -s -- [args]`
19 changes: 11 additions & 8 deletions change
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ usage() {
echo "change init"
echo " creates a $change_file with the first version"
echo ""
echo "change auth"
echo " prompts you for a person access token that"
echo " can be used for posting releases"
echo "change auth [TOKEN]"
echo " prompts you for a personal access token that"
echo " can be used when posting releases"
echo " optional: give token as argument instead of prompt"
echo ""
echo "change post"
echo " posts a GitHub release for the latest version"
Expand Down Expand Up @@ -183,9 +184,11 @@ make_and_push_tag() {
}

auth() {
echo "enter a personal access token"
printf "token: "
read -r token
token=$1
[ ! "$token" ] &&
echo "enter a personal access token" &&
printf "token: " &&
read -r token

[ ! "$token" ] && { echo "invalid token" >&2; return 1; }
[ ! -d "$auth_dir" ] && mkdir -p "$auth_dir"
Expand Down Expand Up @@ -275,11 +278,11 @@ modify_file() {
done
}

[ "$2" ] && { echo "change currently accepts only one argument" >&2; exit 1; }
[ ! "$1" ] && { modify_file; exit; }
[ "$1" = "auth" ] && { auth "$2"; exit; }
[ "$2" ] && { echo "only auth can use more than one argument" >&2; exit 1; }
[ "$1" = "init" ] && { init; exit; }
[ "$1" = "tag" ] && { make_and_push_tag; exit; }
[ "$1" = "auth" ] && { auth; exit; }
[ "$1" = "post" ] && { post_release; exit; }
[ "$1" = "all" ] && { run_all; exit; }
[ "$1" = "-h" ] && { usage; exit; }
Expand Down

0 comments on commit 008a93c

Please sign in to comment.