Skip to content

Commit

Permalink
refactor: restructure for installation with Fisher
Browse files Browse the repository at this point in the history
  • Loading branch information
dbohdan committed Jan 28, 2024
1 parent 969051a commit e3c254f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and also fish lists as Redis lists.

- [Requirements](#requirements)
- [Usage](#usage)
- [Installation](#installation)
- [Motivation](#motivation)
- [Against complex scripting in fish](#against-complex-scripting-in-fish)
- [License](#license)
Expand Down Expand Up @@ -45,6 +46,23 @@ See
[`example.fish`](example.fish)
for an example of how you can use redfish.

## Installation

### Using Fisher

To install redfish with [Fisher](https://github.com/jorgebucaran/fisher),
run the command:

```fish
fisher install dbohdan/redfish
```

### Manual

1. Clone the repository
or download and extract a source archive.
2. Run `install.fish`.

## Motivation

I wrote redfish as another way to have
Expand Down
19 changes: 8 additions & 11 deletions redfish.fish → functions/redfish.fish
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# redfish: use Redis as a key-value store from fish.
# redfish: Use Redis from the fish shell.
# Copyright (c) 2023-2024 D. Bohdan. License: MIT.
#
# Installation:
# Put this file in $__fish_config_dir/conf.d/.
#
# Requirements:
# * fish 3.4.1 or later (older versions may work but have not been tested);
# * redis-cli(1);
# * a Redis server (local by default).

if not set --query __redfish_redis_cli_args
set --global __redfish_redis_cli_args
end
# - fish 3.4 or later (older versions do not work);
# - redis-cli(1);
# - A Redis server (local by default).

function redfish --no-scope-shadowing
if not set --query __redfish_redis_cli_args
set --global __redfish_redis_cli_args
end

if test (count $argv) -eq 0
printf 'redfish: missing subcommand\n' >/dev/stderr
return 1
Expand Down
6 changes: 2 additions & 4 deletions install.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

cd "$(path dirname "$(status filename)")"

set --local src redfish.fish
set --local dst $__fish_config_dir/conf.d/redfish.fish
set --local src functions/redfish.fish
set --local dst $__fish_config_dir/functions/redfish.fish

if not cp $src $dst
return 1
end

printf 'copied "%s" to "%s"\n' $src $dst
printf '\nTo use redfish without restarting fish, run the folowing command:%s\n'
printf 'source %s\n' (string escape $dst)
7 changes: 4 additions & 3 deletions tests.fish
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#! /usr/bin/env fish
# redfish: use Redis as a key-value store from fish.
# Copyright (c) 2023-2024 D. Bohdan. License: MIT.
# redfish: Use Redis from the fish shell.
# Copyright (c) 2023-2024 D. Bohdan.
# License: MIT.

cd "$(path dirname "$(status filename)")"
source redfish.fish
source functions/redfish.fish

begin
set --local initial foo1\nfoo2 bar βαζ
Expand Down

0 comments on commit e3c254f

Please sign in to comment.