Skip to content

Commit c9b44bb

Browse files
authored
Fix: Error on passing -h without mode (#55)
* docs: usage literature updates * feat: create a cli-config symlink to setup.sh * docs: update setup.sh to cli-config * chore: run a lint fix
1 parent 13d062c commit c9b44bb

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

cli-config

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./setup.sh

details.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ $ git checkout main
7474
You might not need all the things that cli-config installs. To see the list of tools available pass the `--help` switch.
7575
You can pass the list of tools to install with the `-t` or `--tools` switch, like so
7676
```bash
77-
$ ./setup.sh install --tools antigen,nvm,ohmyposh
77+
$ ./cli-config install --tools antigen,nvm,ohmyposh
7878
```
7979

8080
3. Run the setup again
8181

82-
After thinking about it, I've decided that cli-config should retain the older installation even if you run `./setup.sh` multiple times. So, incase you want to reinstall any tool, you can delete that folder or the entire `current` folder before running setup again. (Example: If you want to reinstall nvm, delete the `current/nvm` folder and run `setup.sh` again)
82+
After thinking about it, I've decided that cli-config should retain the older installation even if you run `./cli-config` multiple times. So, incase you want to reinstall any tool, you can delete that folder or the entire `current` folder before running setup again. (Example: If you want to reinstall nvm, delete the `current/nvm` folder and run `cli-config` again)

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ should give you the path to all the four executables, like so:
3535
3636
## install
3737

38-
Use the `init.sh` script to setup in a single step! You can visit the link - https://raw.githubusercontent.com/mrsauravsahu/cli-config/main/init.sh to see its raw contents, which is just a git clone followed by calling the `setup.sh` script.
38+
Use the `init.sh` script to setup in a single step! You can visit the link - https://raw.githubusercontent.com/mrsauravsahu/cli-config/main/init.sh to see its raw contents, which is just a git clone followed by calling the `cli-config` script.
3939

4040
```bash
4141
wget -O- https://raw.githubusercontent.com/mrsauravsahu/cli-config/main/init.sh | zsh -s -- -p default

src/defs/main.zsh

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ main() {
1010

1111
prereqs "$@"
1212

13+
read_options "$@"
1314
# check if mode is valid
1415
modes=('install' 'configure' 'uninstall')
1516
IS_MODE_VALID='false'
@@ -20,19 +21,15 @@ main() {
2021
done
2122

2223
if [ "${IS_MODE_VALID}" = 'false' ]; then
23-
if [ "$mode" = "" ]; then
24-
echo -n "Mode not selected. "
25-
else
26-
echo -n "Invalid mode '$mode' selected. "
24+
if [ ! "$mode" = "" ]; then
25+
echo "Invalid mode '$mode' selected. "
2726
fi
2827
usage
2928
exit
3029
else
3130
shift # <-- already read mode argument so shifting once
3231

3332
. $CLI_CONFIG_ROOT/src/defs/${mode}.zsh
34-
35-
read_options "$@"
3633
$mode "$@"
3734
fi
3835
}

src/defs/usage.zsh

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
usage() {
66
modes=('install' 'configure')
77
profiles=($(ls -1 "${CLI_CONFIG_ROOT}/profiles"))
8+
tools=$(ls -1 $CLI_CONFIG_ROOT/src/installers | sed 's/\..*$//g' | sort | uniq | xargs | sed 's/ /,/g')
89

9-
printf "\nCLI-CONFIG \n\n"
10+
printf "CLI-CONFIG\n"
1011

1112
modes_str=$(array_str ", " "${modes[@]}")
12-
echo -n "./setup.sh <${modes_str}> "
13+
profiles_str=$(array_str "/" "${profiles[@]}")
1314

14-
profiles_str=$(array_str ", " "${profiles[@]}")
15-
printf "[-p|--profile] ${profiles_str} "
16-
printf "[-t|--tools $(ls -1 $CLI_CONFIG_ROOT/src/installers | sed 's/\..*$//g' | sort | uniq | xargs | sed 's/ /,/g')]\n\n"
15+
echo "./setup.sh <mode> [-p|--profile=profileName] [-t|--tools=tool1,tool2]"
16+
printf "\n\n"
17+
echo "mode: ${modes_str} "
18+
echo "profile: ${profiles_str} "
19+
printf "tools: ${tools}\n"
1720
}

0 commit comments

Comments
 (0)