diff --git a/flake.lock b/flake.lock index 23c7383..c1c72b8 100644 --- a/flake.lock +++ b/flake.lock @@ -128,9 +128,25 @@ "type": "github" } }, + "kabalist": { + "flake": false, + "locked": { + "lastModified": 1658067642, + "narHash": "sha256-h3eHpVqKNZ3Ox6px4w8Vl6ewaWB8k7YgmS0Bx7N9psc=", + "owner": "traxys", + "repo": "kabalist", + "rev": "19fd995f481af3294ff919b2078aa2cf97fe4a5f", + "type": "github" + }, + "original": { + "owner": "traxys", + "repo": "kabalist", + "type": "github" + } + }, "naersk": { "inputs": { - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs" }, "locked": { "lastModified": 1655042882, @@ -148,7 +164,25 @@ }, "naersk_2": { "inputs": { - "nixpkgs": "nixpkgs_6" + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1655042882, + "narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=", + "owner": "nix-community", + "repo": "naersk", + "rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "naersk_3": { + "inputs": { + "nixpkgs": "nixpkgs_7" }, "locked": { "lastModified": 1650265945, @@ -191,7 +225,7 @@ "nix-alien": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "poetry2nix": "poetry2nix" }, "locked": { @@ -210,7 +244,7 @@ }, "nix-ld": { "inputs": { - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "utils": "utils_2" }, "locked": { @@ -229,6 +263,20 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1657975505, + "narHash": "sha256-juMbw+GY2ycTrg3QbdFfEQs6P3FJeoYEv8aMVl2EZsg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d6df226c53d46821bd4773bd7ec3375f30238edb", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1657828896, "narHash": "sha256-yxK3kRjSpKlrnR4kmqe2uwpys9LRc/Fckb4Ydwzomw4=", @@ -244,7 +292,7 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_3": { "locked": { "lastModified": 1652536154, "narHash": "sha256-d+y62beDhz2/l65SBAkxwtvTBzw3hgU1kECogyncKYM=", @@ -259,7 +307,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1657802959, "narHash": "sha256-9+JWARSdlL8KiH3ymnKDXltE1vM+/WEJ78F5B1kjXys=", @@ -275,7 +323,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_5": { "locked": { "lastModified": 1656338871, "narHash": "sha256-+LOvZFt3MpWtrxXLH4igQtRVzyD43VnuTJjDVbt7phY=", @@ -289,7 +337,7 @@ "type": "indirect" } }, - "nixpkgs_5": { + "nixpkgs_6": { "locked": { "lastModified": 1656401090, "narHash": "sha256-bUS2nfQsvTQW2z8SK7oEFSElbmoBahOPtbXPm0AL3I4=", @@ -305,7 +353,7 @@ "type": "github" } }, - "nixpkgs_6": { + "nixpkgs_7": { "locked": { "lastModified": 1650647760, "narHash": "sha256-Ng8CGYLSTxeI+oEux0x+tSRA6K7ydoyfJNQf56ld+Uo=", @@ -319,7 +367,7 @@ "type": "indirect" } }, - "nixpkgs_7": { + "nixpkgs_8": { "locked": { "lastModified": 1650161686, "narHash": "sha256-70ZWAlOQ9nAZ08OU6WY7n4Ij2kOO199dLfNlvO/+pf8=", @@ -338,7 +386,7 @@ "nvim-traxys": { "inputs": { "flake-utils": "flake-utils_2", - "naersk": "naersk", + "naersk": "naersk_2", "neovim-flake": "neovim-flake", "nixpkgs": [ "nixpkgs" @@ -1066,9 +1114,11 @@ "root": { "inputs": { "home-manager": "home-manager", + "kabalist": "kabalist", + "naersk": "naersk", "nix-alien": "nix-alien", "nix-ld": "nix-ld", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_4", "nvim-traxys": "nvim-traxys", "rust-overlay": "rust-overlay", "xdg-ninja": "xdg-ninja", @@ -1078,7 +1128,7 @@ "rust-overlay": { "inputs": { "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_5" + "nixpkgs": "nixpkgs_6" }, "locked": { "lastModified": 1658026364, @@ -1177,8 +1227,8 @@ "dotacat": "dotacat", "fast-syntax-highlighting": "fast-syntax-highlighting", "flake-utils": "flake-utils_5", - "naersk": "naersk_2", - "nixpkgs": "nixpkgs_7", + "naersk": "naersk_3", + "nixpkgs": "nixpkgs_8", "powerlevel10k": "powerlevel10k", "zsh-nix-shell": "zsh-nix-shell" }, diff --git a/flake.nix b/flake.nix index 4313671..efcd5ef 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,11 @@ flake = false; }; rust-overlay.url = "github:oxalica/rust-overlay"; + naersk.url = "github:nix-community/naersk"; + kabalist = { + url = "github:traxys/kabalist"; + flake = false; + }; }; outputs = { @@ -53,6 +58,10 @@ buildInputs = [jq glow bash]; nativeBuildInputs = [makeWrapper]; }; + kabalist_cli = inputs.naersk.lib."${system}".buildPackage { + cargoBuildOptions = opts: opts ++ ["--package=kabalist_cli"]; + root = inputs.kabalist; + }; }) ]; }) diff --git a/home.nix b/home.nix index fd6bd9d..ff54063 100644 --- a/home.nix +++ b/home.nix @@ -34,6 +34,8 @@ in { gcc11 nix-alien xdg-ninja + bc + kabalist_cli ]; services = { @@ -70,15 +72,19 @@ in { source = ./scripts; recursive = true; }; + ".zfunc" = { + source = ./zfunc; + recursive = true; + }; }; programs.zsh = { + initExtraBeforeCompInit = '' + fpath+="$HOME/.zfunc" + ''; shellAliases = { new-direnv = "nix flake new -t github:nix-community/nix-direnv"; }; - initExtra = '' - fpath+="$HOME/.zfunc" - ''; }; # This value determines the Home Manager release that your diff --git a/zfunc/_kabalist_cli b/zfunc/_kabalist_cli new file mode 100644 index 0000000..8af2955 --- /dev/null +++ b/zfunc/_kabalist_cli @@ -0,0 +1,525 @@ +#compdef kabalist_cli + +autoload -U is-at-least + +_kabalist_cli() { + typeset -A opt_args + typeset -a _arguments_options + local ret=1 + + if is-at-least 5.2; then + _arguments_options=(-s -S -C) + else + _arguments_options=(-s -C) + fi + + local context curcontext="$curcontext" state line + _arguments "${_arguments_options[@]}" \ +'-u+[]:URL: ' \ +'--url=[]:URL: ' \ +'-h[Print help information]' \ +'--help[Print help information]' \ +":: :_kabalist_cli_commands" \ +"*::: :->kabalist_cli" \ +&& ret=0 + case $state in + (kabalist_cli) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:kabalist_cli-command-$line[1]:" + case $line[1] in + (account) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +":: :_kabalist_cli__account_commands" \ +"*::: :->account" \ +&& ret=0 + + case $state in + (account) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:kabalist_cli-account-command-$line[1]:" + case $line[1] in + (login) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':name:' \ +'::password:' \ +&& ret=0 +;; +(recover) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':id:' \ +'::password:' \ +&& ret=0 +;; +(register) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':id:' \ +':username:' \ +'::password:' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'*::subcommand -- The subcommand whose help message to display:' \ +&& ret=0 +;; + esac + ;; +esac +;; +(list) +_arguments "${_arguments_options[@]}" \ +'-t+[]:TOKEN: ' \ +'--token=[]:TOKEN: ' \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':list:' \ +":: :_kabalist_cli__list_commands" \ +"*::: :->list" \ +&& ret=0 + + case $state in + (list) + words=($line[2] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:kabalist_cli-list-command-$line[2]:" + case $line[2] in + (delete) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +&& ret=0 +;; +(add) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':name:' \ +'::amount:' \ +&& ret=0 +;; +(item) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':item:' \ +":: :_kabalist_cli__list__item_commands" \ +"*::: :->item" \ +&& ret=0 + + case $state in + (item) + words=($line[2] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:kabalist_cli-list-item-command-$line[2]:" + case $line[2] in + (tick) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +&& ret=0 +;; +(update) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +'::name:' \ +'::amount:' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'*::subcommand -- The subcommand whose help message to display:' \ +&& ret=0 +;; + esac + ;; +esac +;; +(share) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +":: :_kabalist_cli__list__share_commands" \ +"*::: :->share" \ +&& ret=0 + + case $state in + (share) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:kabalist_cli-list-share-command-$line[1]:" + case $line[1] in + (add) +_arguments "${_arguments_options[@]}" \ +'-r[]' \ +'--readonly[]' \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':name:' \ +&& ret=0 +;; +(delete) +_arguments "${_arguments_options[@]}" \ +'--all[]' \ +'-h[Print help information]' \ +'--help[Print help information]' \ +'*::names:' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'*::subcommand -- The subcommand whose help message to display:' \ +&& ret=0 +;; + esac + ;; +esac +;; +(public) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +":: :_kabalist_cli__list__public_commands" \ +"*::: :->public" \ +&& ret=0 + + case $state in + (public) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:kabalist_cli-list-public-command-$line[1]:" + case $line[1] in + (set) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +&& ret=0 +;; +(remove) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'*::subcommand -- The subcommand whose help message to display:' \ +&& ret=0 +;; + esac + ;; +esac +;; +(history) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +'::search:' \ +&& ret=0 +;; +(pantry) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +":: :_kabalist_cli__list__pantry_commands" \ +"*::: :->pantry" \ +&& ret=0 + + case $state in + (pantry) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:kabalist_cli-list-pantry-command-$line[1]:" + case $line[1] in + (add) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':name:' \ +':target:' \ +&& ret=0 +;; +(refill) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'*::subcommand -- The subcommand whose help message to display:' \ +&& ret=0 +;; + esac + ;; +esac +;; +(help) +_arguments "${_arguments_options[@]}" \ +'*::subcommand -- The subcommand whose help message to display:' \ +&& ret=0 +;; + esac + ;; +esac +;; +(lists) +_arguments "${_arguments_options[@]}" \ +'-t+[]:TOKEN: ' \ +'--token=[]:TOKEN: ' \ +'-h[Print help information]' \ +'--help[Print help information]' \ +":: :_kabalist_cli__lists_commands" \ +"*::: :->lists" \ +&& ret=0 + + case $state in + (lists) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:kabalist_cli-lists-command-$line[1]:" + case $line[1] in + (create) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':list:' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'*::subcommand -- The subcommand whose help message to display:' \ +&& ret=0 +;; + esac + ;; +esac +;; +(completions) +_arguments "${_arguments_options[@]}" \ +'-h[Print help information]' \ +'--help[Print help information]' \ +':shell:' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'*::subcommand -- The subcommand whose help message to display:' \ +&& ret=0 +;; + esac + ;; +esac +} + +(( $+functions[_kabalist_cli_commands] )) || +_kabalist_cli_commands() { + local commands; commands=( +'account:' \ +'list:' \ +'lists:' \ +'completions:' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'kabalist_cli commands' commands "$@" +} +(( $+functions[_kabalist_cli__account_commands] )) || +_kabalist_cli__account_commands() { + local commands; commands=( +'login:' \ +'recover:' \ +'register:' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'kabalist_cli account commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__add_commands] )) || +_kabalist_cli__list__add_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list add commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__pantry__add_commands] )) || +_kabalist_cli__list__pantry__add_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list pantry add commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__share__add_commands] )) || +_kabalist_cli__list__share__add_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list share add commands' commands "$@" +} +(( $+functions[_kabalist_cli__completions_commands] )) || +_kabalist_cli__completions_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli completions commands' commands "$@" +} +(( $+functions[_kabalist_cli__lists__create_commands] )) || +_kabalist_cli__lists__create_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli lists create commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__delete_commands] )) || +_kabalist_cli__list__delete_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list delete commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__share__delete_commands] )) || +_kabalist_cli__list__share__delete_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list share delete commands' commands "$@" +} +(( $+functions[_kabalist_cli__account__help_commands] )) || +_kabalist_cli__account__help_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli account help commands' commands "$@" +} +(( $+functions[_kabalist_cli__help_commands] )) || +_kabalist_cli__help_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli help commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__help_commands] )) || +_kabalist_cli__list__help_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list help commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__item__help_commands] )) || +_kabalist_cli__list__item__help_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list item help commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__pantry__help_commands] )) || +_kabalist_cli__list__pantry__help_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list pantry help commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__public__help_commands] )) || +_kabalist_cli__list__public__help_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list public help commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__share__help_commands] )) || +_kabalist_cli__list__share__help_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list share help commands' commands "$@" +} +(( $+functions[_kabalist_cli__lists__help_commands] )) || +_kabalist_cli__lists__help_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli lists help commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__history_commands] )) || +_kabalist_cli__list__history_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list history commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__item_commands] )) || +_kabalist_cli__list__item_commands() { + local commands; commands=( +'tick:' \ +'update:' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'kabalist_cli list item commands' commands "$@" +} +(( $+functions[_kabalist_cli__list_commands] )) || +_kabalist_cli__list_commands() { + local commands; commands=( +'delete:' \ +'add:' \ +'item:' \ +'share:' \ +'public:' \ +'history:' \ +'pantry:' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'kabalist_cli list commands' commands "$@" +} +(( $+functions[_kabalist_cli__lists_commands] )) || +_kabalist_cli__lists_commands() { + local commands; commands=( +'create:' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'kabalist_cli lists commands' commands "$@" +} +(( $+functions[_kabalist_cli__account__login_commands] )) || +_kabalist_cli__account__login_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli account login commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__pantry_commands] )) || +_kabalist_cli__list__pantry_commands() { + local commands; commands=( +'add:' \ +'refill:' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'kabalist_cli list pantry commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__public_commands] )) || +_kabalist_cli__list__public_commands() { + local commands; commands=( +'set:' \ +'remove:' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'kabalist_cli list public commands' commands "$@" +} +(( $+functions[_kabalist_cli__account__recover_commands] )) || +_kabalist_cli__account__recover_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli account recover commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__pantry__refill_commands] )) || +_kabalist_cli__list__pantry__refill_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list pantry refill commands' commands "$@" +} +(( $+functions[_kabalist_cli__account__register_commands] )) || +_kabalist_cli__account__register_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli account register commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__public__remove_commands] )) || +_kabalist_cli__list__public__remove_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list public remove commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__public__set_commands] )) || +_kabalist_cli__list__public__set_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list public set commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__share_commands] )) || +_kabalist_cli__list__share_commands() { + local commands; commands=( +'add:' \ +'delete:' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'kabalist_cli list share commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__item__tick_commands] )) || +_kabalist_cli__list__item__tick_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list item tick commands' commands "$@" +} +(( $+functions[_kabalist_cli__list__item__update_commands] )) || +_kabalist_cli__list__item__update_commands() { + local commands; commands=() + _describe -t commands 'kabalist_cli list item update commands' commands "$@" +} + +_kabalist_cli "$@"