@@ -75,19 +75,25 @@ function print_source_help () {
7575 echo " if 'source' is given as 'owner/repo', it will default to 'github:owner/repo'"
7676}
7777
78+ function show_tree_without_default () {
79+ exa ${3} -Th " $1 " | rg -v " (default\.nix|profiles|modules)" | tail -n +1 || echo " $2 "
80+ }
81+
7882GIT_CACHE=" $HOME /.cache/bud/git"
7983
8084case " $1 " in
8185 " show" )
8286 shift 1
8387
8488 url=" $1 "
89+ ty=" $2 "
8590
8691 if [[ -z " $url " ]]; then
87- echo " Show profiles available in the specified source\n"
88- echo " Usage: show source\n"
92+ echo " Show profiles / modules / users / hosts available in the specified source\n"
93+ echo " Usage: show source (profiles|users|hosts|modules) \n"
8994 print_source_help
90- echo " if 'source' is '.', it will show your own profiles"
95+ echo " if 'source' is '.', it will show your own profiles / users / hosts / modules\n"
96+ echo " if none of 'profiles', 'users', 'hosts' or 'modules' are specified, it will default to 'profiles'"
9197 exit 1
9298 fi
9399
@@ -100,19 +106,37 @@ case "$1" in
100106 fetch_repo " $url " " $repo_path " || exit $?
101107 fi
102108
103- echo " nixos profiles:"
104- exa -Th " $repo_path /profiles" | grep -v " default.nix" | tail -n +2 || echo " no nixos profiles found"
105- echo " home-manager profiles:"
106- exa -Th " $repo_path /users/profiles" | grep -v " default.nix" | tail -n +2 || echo " no home-manager profiles found"
109+ case " $ty " in
110+ " users" )
111+ echo " users:"
112+ show_tree_without_default " $repo_path /users" " no users found" " --level=1"
113+ ;;
114+ " hosts" )
115+ echo " hosts:"
116+ show_tree_without_default " $repo_path /hosts" " no hosts found" " --level=1"
117+ ;;
118+ " modules" )
119+ echo " nixos modules:"
120+ show_tree_without_default " $repo_path /modules" " no nixos profiles found"
121+ echo " home-manager modules:"
122+ show_tree_without_default " $repo_path /users/modules" " no home-manager profiles found"
123+ ;;
124+ * )
125+ echo " nixos profiles:"
126+ show_tree_without_default " $repo_path /profiles" " no nixos profiles found"
127+ echo " home-manager profiles:"
128+ show_tree_without_default " $repo_path /users/profiles" " no home-manager profiles found"
129+ ;;
130+ esac
107131 ;;
108132 " remove" )
109133 shift 1
110134
111135 attr_origpath=$1
112136
113137 if [[ -z " $attr_origpath " ]]; then
114- echo " Remove a profile from your config\n"
115- echo " Usage: remove ( nixos|hm). profiles.[PROFILE ]"
138+ echo " Remove a profile / user / host / module from your config\n"
139+ echo " Usage: remove nixos.(profiles|users|hosts|modules).[NAME] / add source hm.( profiles|modules).[NAME ]"
116140 exit 1
117141 fi
118142
@@ -133,8 +157,8 @@ case "$1" in
133157 attr_origpath=$2
134158
135159 if [[ -z " $url " || -z " $attr_origpath " ]]; then
136- echo " Add a profile from the specified source\n"
137- echo " Usage: add source ( nixos|hm). profiles.[PROFILE ]\n"
160+ echo " Add a profile / user / host / module from the specified source\n"
161+ echo " Usage: add source nixos.(profiles|users|hosts|modules).[NAME] / add source hm.( profiles|modules).[NAME ]\n"
138162 print_source_help
139163 exit 1
140164 fi
@@ -157,9 +181,9 @@ case "$1" in
157181 ;;
158182 * )
159183 echo " Available subcommands are:"
160- echo " - 'add': Add a profile from the specified source"
161- echo " - 'show': Show profiles available in the specified source"
162- echo " - 'remove': Remove a profile from your config\n"
184+ echo " - 'add': Add a profile / user / host / module from the specified source"
185+ echo " - 'show': Show profiles / users / hosts / modules available in the specified source"
186+ echo " - 'remove': Remove a profile / user / host / module from your config\n"
163187 echo " run 'bud cfg command' for more info about a command"
164188 exit 1
165189 ;;
0 commit comments