Skip to content

Commit

Permalink
Add polish-workflow command
Browse files Browse the repository at this point in the history
The command just opens a given workflows file for editing. And
completions will provide only available files which improve a user
experience.
  • Loading branch information
extsoft committed Apr 6, 2020
1 parent b401a28 commit c9cbdc0
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions completions/_git-elegant
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ _git-elegant (){
'make-workflow:makes a new workflow file for the repository'
'obtain-work:checkouts a remote branch matching by a name'
'polish-work:reapplies branch commits interactively'
'polish-workflow:edits a given workflows file'
'prune-repository:removes useless local branches'
'release-work:releases available work as a new annotated tag'
'save-work:commits current modifications'
Expand Down Expand Up @@ -67,6 +68,10 @@ __ge_complete_commands () {
show-release-notes) __ge_show_release_notes ;;
start-work) __ge_start_work ;;
make-workflow) __ge_make_workflow ;;
polish-workflow)
local files=($(git elegant show-workflows))
_arguments '--help' '--no-workflows' '1:file:(${files[@]})'
;;
*) _arguments '--help' '--no-workflows' ;;
esac
}
Expand Down
5 changes: 5 additions & 0 deletions completions/git-elegant.bash
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ _git_elegant() {
show-release-notes)
COMPREPLY=( $(compgen -W "simple smart ${gecops[*]}" -- ${cursor}) )
;;
polish-workflow)
COMPREPLY=(
$(compgen -W "${opts[*]} $(git elegant show-workflows)" -- ${cursor})
)
;;
*)
COMPREPLY=( $(compgen -W "${gecops[*]}" -- ${cursor}) )
;;
Expand Down
16 changes: 16 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ There are commands used in various situations such as
enhance contribution rules
show-workflows Shows configured workflows in the repository.
make-workflow Makes a new workflow file for the repository.
polish-workflow Edits a given workflows file.

make day-to-day contributions
start-work Creates a new branch.
Expand Down Expand Up @@ -262,6 +263,21 @@ Approximate commands flow is
git rebase --interactive @~5
```

# `polish-workflow`

```bash
usage: git elegant polish-workflow <file>
```

Opens a given workflow file in the default text editor. If given file is not
present, the command raises an error.

Approximate commands flow is
```bash
==>> git elegant polish-workflow .workflows/show-work-ahead
vim .workflows/show-work-ahead
```

# `prune-repository`

```bash
Expand Down
1 change: 1 addition & 0 deletions libexec/git-elegant
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ $(--print-command-in-usage prune-repository)
enhance contribution rules
$(--print-command-in-usage show-workflows)
$(--print-command-in-usage make-workflow)
$(--print-command-in-usage polish-workflow)
make day-to-day contributions
$(--print-command-in-usage start-work)
Expand Down
36 changes: 36 additions & 0 deletions libexec/git-elegant-polish-workflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

command-purpose() {
cat <<MESSAGE
Edits a given workflows file.
MESSAGE
}

command-synopsis() {
cat <<MESSAGE
usage: git elegant polish-workflow <file>
MESSAGE
}

command-description() {
cat<<MESSAGE
Opens a given workflow file in the default text editor. If given file is not
present, the command raises an error.
Approximate commands flow is
\`\`\`bash
==>> git elegant polish-workflow .workflows/show-work-ahead
vim .workflows/show-work-ahead
\`\`\`
MESSAGE
}

default() {
_error-if-empty "${1}" "Please specify a workflow file name"
if test -e ${file}; then
$(git config core.editor) ${file}
else
error-text "The '${file}' file does not exist."
exit 43
fi
}
1 change: 1 addition & 0 deletions tests/git-elegant-show-commands.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ teardown() {
"polish-work"
"show-workflows"
"make-workflow"
"polish-workflow"
)
check git-elegant show-commands
[[ ${#lines[@]} -eq ${#COMMANDS[@]} ]]
Expand Down

0 comments on commit c9cbdc0

Please sign in to comment.