Skip to content

Commit

Permalink
feat(quiet, exit status): output to stdout or stderr with quiet option
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed May 9, 2020
1 parent 78bb6d7 commit e671a87
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 84 deletions.
30 changes: 17 additions & 13 deletions README.md
Expand Up @@ -161,18 +161,18 @@ Default is regular.
### Options

```shell
[(--add | -a )] [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] arg
| (--clear-session | -c)
| (--erase | -e ) [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] arg
[(--add | -a )] [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] [--quiet] arg
| (--clear-session | -c) [--quiet]
| (--erase | -e ) [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] [--quiet] arg
| (--expand | -x) arg
| --export-aliases [(--session | -S) | (--user | -U)] [(--global | -g)] arg
| (--help | -h)
| --import-aliases [(--global | -g)] [--dry-run]
| --import-fish [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] arg
| --import-git-aliases [(--session | -S) | (--user | -U)] [--dry-run]
| --import-aliases [(--global | -g)] [--dry-run] [--quiet]
| --import-fish [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] [--quiet] arg
| --import-git-aliases [(--session | -S) | (--user | -U)] [--dry-run] [--quiet]
| (--list-abbreviations | -l) [(--session | -S) | (--user | -U)] [(--global | -g) | (--regular | -r)]
| (--list-commands | -L | -s) [(--session | -S) | (--user | -U)] [(--global | -g) | (--regular | -r)]
| (--rename | -R ) [(--session | -S) | (--user | -U)] [(--global | -g)] [(--global | -g)] [--dry-run] args
| (--rename | -R ) [(--session | -S) | (--user | -U)] [(--global | -g)] [(--global | -g)] [--dry-run] [--quiet] args
]
```

Expand All @@ -183,7 +183,7 @@ zsh-abbr has options to add, rename, and erase abbreviations; to add abbreviatio
#### Add

```shell
abbr [(--add | -a)] [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] ABBREVIATION=EXPANSION
abbr [(--add | -a)] [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] [--quiet] ABBREVIATION=EXPANSION
```

Add a new abbreviation.
Expand Down Expand Up @@ -241,7 +241,7 @@ Erase all session abbreviations.
#### Erase

```shell
abbr (--erase | -e) [(--session | -S) | (--user | -U)] [(--global | -g)] ABBREVIATION
abbr (--erase | -e) [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] [--quiet] ABBREVIATION
```

Erase an abbreviation.
Expand Down Expand Up @@ -306,7 +306,7 @@ alias g='git'
##### Aliases

```shell
abbr --import-aliases [--dry-run]
abbr --import-aliases [--dry-run] [--quiet]
```

Add regular abbreviations for every regular alias in the session, and global abbreviations for every global alias in the session.
Expand All @@ -328,7 +328,7 @@ Use `--dry-run` to see what would result, without making any actual changes.
##### Git Aliases

```shell
abbr --import-git-aliases [--dry-run]
abbr --import-git-aliases [--dry-run] [--quiet]
```

Add two abbreviations for every Git alias available in the current session: a global abbreviation where the WORD is prefixed with `g`, and a command abbreviation. For both the EXPANSION is prefixed with `git[Space]`.
Expand Down Expand Up @@ -363,7 +363,7 @@ Use `--dry-run` to see what would result, without making any actual changes.
##### Fish Abbreviations

```shell
abbr --import-fish [(--session | -S) | (--user | -U)] [(--global|-g)] FILE [--dry-run]
abbr --import-fish [(--session | -S) | (--user | -U)] [(--global|-g)] FILE [--dry-run] [--quiet]
```

Import fish abbr-syntax abbreviations (`abbreviation expansion` as compared to zsh abbr's `abbreviation=expansion`).
Expand Down Expand Up @@ -478,7 +478,7 @@ b="ball"
#### Rename

```shell
abbr (--rename | -R) [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] OLD NEW
abbr (--rename | -R) [(--session | -S) | (--user | -U)] [(--global | -g)] [--dry-run] [--quiet] OLD NEW
```

Rename an abbreviation.
Expand Down Expand Up @@ -573,6 +573,10 @@ Check the [Issues](https://github.com/olets/zsh-abbr/issues) to see if your topi

This project loosely follows the [Angular commit message conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit). This helps with searchability and with the changelog, which is generated automatically and touched up by hand only if necessary. Use the commit message format `<type>(<scope>): <subject>`, where `<type>` is **feat** for new or changed behavior, **fix** for fixes, **docs** for documentation, **style** for under the hood changes related to for example zshisms, **refactor** for other refactors, **test** for tests, or **chore** chore for general maintenance (this will be used primarily by maintainers not contributors, for example for version bumps). `<scope>` is more loosely defined. Look at the [commit history](https://github.com/olets/zsh-abbr/commits/master) for ideas.

To force a dry run without passing `--dry-run`, set `ZSH_ABBR_DRY_RUN` to `1.

To force quiet mode with passing `--quiet`, set `ZSH_ABBR_QUIET` to `1`.

Tests are in the `tests` directory. To run them, replace `zsh-abbr` with `zsh-abbr/tests` in .zshrc. For example, zinit users will run

```shell
Expand Down
6 changes: 3 additions & 3 deletions ROADMAP.md
Expand Up @@ -14,11 +14,11 @@ Key:

## 3.x

- [ ] stronger tests?
- [ ] log message about what change was made
- [ ] testing framework?
- [x] log message about what change was made
- [ ] Git status-like: when job finishes, list actions taken by group (added, erased, couldn't add (already exists), could erase (doesn't exist), didn't add (e.g. git function alias))
- [ ] color coded
- [ ] support --quiet option and ZSH_ABBR_QUIET env variable
- [x] support --quiet option and ZSH_ABBR_QUIET env variable
- [ ] maybe split abbr into its own file, and autoload it
- [ ] sync as last step of initialization

Expand Down
13 changes: 10 additions & 3 deletions man/abbr.txt
Expand Up @@ -153,13 +153,20 @@ Options
o --dry-run Show whats the result of the command would be.


All except for --clear-session, --expand, --export-aliases, --list-
abbreviations, and --list-commands can be run with reduced output:


o --quiet Do not log success, warning, or error messages.


See INTERNALS for more information.


EXAMPLES
abbr gco="git checkout"

"gco" will be expanded as "git checkout" when it is the first
"gco" will be expanded as "git checkout" when it is the first
word in the command, in all open and future sessions.


Expand All @@ -177,9 +184,9 @@ EXAMPLES

abbr -e -S -g gco;

Erase the global session abbreviation "gco". Note that because
Erase the global session abbreviation "gco". Note that because
expansion is triggered by [SPACE] and [ENTER], the semicolon (;)
is necessary to prevent expansion when operating on global
is necessary to prevent expansion when operating on global
abbreviations.


Expand Down
9 changes: 9 additions & 0 deletions man/man1/abbr.1
Expand Up @@ -142,6 +142,15 @@ Show whats the result of the command would be.

.RE

All except for \fB\-\-clear-session\fR, \fB\-\-expand\fR, \fB\-\-export-aliases\fR, \fB\-\-list-abbreviations\fR, and \fB\-\-list-commands\fR can be run with reduced output:
.RS

.IP \(bu
\fB\-\-quiet\fR
Do not log success, warning, or error messages.

.RE

See \fBINTERNALS\fR for more information.

.SH EXAMPLES
Expand Down
1 change: 1 addition & 0 deletions tests/tests.zsh
@@ -1,3 +1,4 @@
ZSH_ABBR_QUIET=1
ZSH_ABBR_USER_PATH=${0:A:h}/abbreviations.$RANDOM
touch $ZSH_ABBR_USER_PATH
source ${0:A:h}/../zsh-abbr.zsh
Expand Down

0 comments on commit e671a87

Please sign in to comment.