Commit Graph

7 Commits

Author SHA1 Message Date
Marty Oehme d44cbf5b74
Add long-form option parsing
ci/woodpecker/push/woodpecker Pipeline was successful Details
So far we could only add single-letter (POSIX) options: `-e`, `-n` and
so forth. Since we will run out of alphabet at some point, this commit
introduces parsing of multi-letter long-form (gnu) options (plus any
modern application should really support it anyways):
`--echo`, `--noline`.

Additionally, we support supplying long-form options that supply a value
both in the spaced (`--hist-limit 0`) and the equals (`--hist-limit=0`)
forms. Short, long, spaced, equals can be mixed and matched between
freely.

Lastly, we retain the ability to concatenate short options as before
(`-ne` is valid, as is `-P0` for the respective options above).

This should cover all bases and does not complicate the code too much to
keep a coherent overview.

Changed several code samples in the documentation to make
use of short- or long-form options to point out
possibility.
2023-08-26 14:37:44 +02:00
Marty Oehme 56ae0f1bab
🐛 Pass through stdin to custom typing tool (#19)
Previously, stdin contents were consumed and then not passed through to
the typing tool. With this commit, they are correctly passed to any
custom tool's stdin.

Fixes #19.
2023-04-11 23:00:19 +02:00
Marty Oehme 71d5dc455d
🦊 Exit status 1 on cancelled selection (#20)
When making no selection, i.e. cancelling during the selection process
the program will return status code 1, whereas before it would carry the
same return code as when making an emoji selection.

Fixes #20.
2023-04-11 22:33:26 +02:00
Marty Oehme 59d436a944
🦊 BREAKING: Use new XDG Base specification for state (#5)
ci/woodpecker/push/woodpecker Pipeline was successful Details
Switched the history from using the XDG_CACHE_HOME directory by default
to use XDG_STATE_HOME by default.

This makes sense since cache can (and should be prepared to) be wiped at
any moment and the program functionality should not be hindered by this.
Since we need to retain history through such wipes the newly introduced
state directory is the perfect match for keeping the history file in.

This does constitute a breaking change for existing histories which need
to be moved to the new directory if they made use of the old cache
directory.

Concurrent with this we are renaming `XDG_CACHE_LOCATION` environment
variable to `XDG_HISTORY_LOCATION` so this is a second breaking change
for those using a custom location for their histories.

This change attempts to make the naming scheme coherent and remove some
left-over naming cruft from the old location being the cache directory.

This provides one of the larger changes to the program so far.

Fixes #5.
2022-11-19 15:03:14 +01:00
Yann Büchau d03068dba7
Add -n option to prevent newline after emoji (#12)
ci/woodpecker/push/woodpecker Pipeline was successful Details
Adds another commandline option `-n` to the application which prevents
newlines from being added at the end of each output.
Disabled by default.

Co-authored-by: Marty Oehme <marty.oehme@gmail.com>
2022-09-27 21:01:44 +02:00
Marty Oehme 7e8fc0c51a
Add ability to execute multiple command options
Can combine command options (-c, -t, -e) in any way to simultaneously
clip, type and/or echo the picked results.
Still defaults to clipping, as before.

If a custom default command is given with `BEMOJI_DEFAULT_CMD` env var,
then invoking bemoji without any command option will invoke this
command. Otherwise, the other commands are added to the default given
command.

Additionally, refactor echo command to mirror other commands
Both typing and clipping simply invoke the corresponding program
function while echo had an extra role so far. This adjusts the echo
command to also work the same way.
2022-08-06 11:46:06 +02:00
Marty Oehme 28aa2aa522
🧪 Add tests for clipping, echo and typing command
Added a simple test for each of the base command options: echo, type,
clip. It uses custom commands set through environment options so does
not yet test the actual default command logic (finding a typer,
clipper), that is still a TODO.

Also split tests into tests concerning commands of the program and tests
concerning the directory settings and options of the program, to avoid
ending up with a single test file spanning hundreds of lines.
2022-08-06 10:02:34 +02:00