Refactor bin to fix argument passing.
This commit is contained in:
parent
efa26131ec
commit
af9105e7ac
2 changed files with 26 additions and 4 deletions
|
@ -14,10 +14,26 @@ let
|
||||||
cp ${../share/fish/completions}/yay.fish $out/share/fish/completions/
|
cp ${../share/fish/completions}/yay.fish $out/share/fish/completions/
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Create main yay binary that uses fish's function path
|
# Create main yay binary that correctly passes args to fish
|
||||||
yayBin = pkgs.writeShellScriptBin "yay" ''
|
yayBin = pkgs.writeShellScriptBin "yay" ''
|
||||||
FUNCTIONS_DIR=$(dirname $(dirname $0))/share/fish/functions
|
FUNCTIONS_DIR=$(dirname $(dirname $0))/share/fish/functions
|
||||||
exec ${lib.getExe pkgs.fish} -c "set fish_function_path \$fish_function_path $FUNCTIONS_DIR; source $FUNCTIONS_DIR/yay.fish; yay_function $@"
|
|
||||||
|
# Create a temporary script to handle command execution
|
||||||
|
TEMP_SCRIPT=$(mktemp -t yay-command.XXXXXX)
|
||||||
|
|
||||||
|
# Write the fish commands to the script
|
||||||
|
cat > $TEMP_SCRIPT << EOF
|
||||||
|
#!/usr/bin/env fish
|
||||||
|
set fish_function_path \$fish_function_path $FUNCTIONS_DIR
|
||||||
|
source $FUNCTIONS_DIR/yay.fish
|
||||||
|
yay_function $@
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Execute the script
|
||||||
|
${lib.getExe pkgs.fish} $TEMP_SCRIPT "$@"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm $TEMP_SCRIPT
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
pkgs.symlinkJoin {
|
pkgs.symlinkJoin {
|
||||||
|
|
10
readme.md
10
readme.md
|
@ -162,9 +162,15 @@ If theres a command you think would be useful to add let me know, I might agree.
|
||||||
|
|
||||||
## Technical Details
|
## Technical Details
|
||||||
|
|
||||||
Yay.nix is implemented as a collection of fish functions that are installed into your system's fish function path. The main `yay` command is a bash script that invokes fish with the correct environment to execute the functions.
|
Yay.nix is implemented as a collection of fish functions that are installed into your system's fish function path. The main `yay` command is a bash script that:
|
||||||
|
|
||||||
All commands and options have competitions making the tool easy to use interactively
|
1. Creates a temporary fish script
|
||||||
|
2. Sets up the fish function path to include the installed functions
|
||||||
|
3. Sources the main yay.fish file
|
||||||
|
4. Passes all command-line arguments to the appropriate fish function
|
||||||
|
5. Cleans up after execution
|
||||||
|
|
||||||
|
All commands and options have completions making the tool easy to use interactively.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue