Add doc function
This commit is contained in:
parent
246ae7051e
commit
460fdd57f8
20
README.md
20
README.md
@ -108,6 +108,26 @@ Using alternate ssh port
|
||||
kickstart bootstrap "-p 2222 vagrant@vagrant"
|
||||
```
|
||||
|
||||
#### doc
|
||||
Show documentation for a kickstart function
|
||||
|
||||
```bash
|
||||
kickstart doc [function name]
|
||||
```
|
||||
|
||||
##### Example
|
||||
List all documented functions
|
||||
|
||||
```bash
|
||||
kickstart doc
|
||||
```
|
||||
|
||||
Show documentation for a function
|
||||
|
||||
```bash
|
||||
kickstart doc kickstart.os
|
||||
```
|
||||
|
||||
|
||||
### Thanks
|
||||
This project was inspired on [sunzi](https://github.com/kenn/sunzi)
|
||||
|
@ -2,7 +2,7 @@ kickstart.profile.add_to_profile() {
|
||||
local file=$1
|
||||
[ ! -f files/$file ] && kickstart.info "File files/$file not found" && exit 1
|
||||
|
||||
local profile_d=`kickstart.profile.profile.d.location`
|
||||
local profile_d=`kickstart.profile.location.profile_d`
|
||||
mkdir -p $profile_d
|
||||
|
||||
cp files/$file $profile_d/$file
|
||||
@ -11,11 +11,6 @@ kickstart.profile.add_to_profile() {
|
||||
kickstart.os.is Mac && kickstart.profile.source_on_configuration_file $file $profile_d `kickstart.profile.location.bash`
|
||||
}
|
||||
|
||||
kickstart.profile.profile.d.location() {
|
||||
kickstart.os.is Ubuntu && echo /etc/profile.d
|
||||
kickstart.os.is Mac && echo ~/.profile.d
|
||||
}
|
||||
|
||||
kickstart.profile.source_on_configuration_file() {
|
||||
local file=$1
|
||||
local profile_d=$2
|
||||
@ -23,6 +18,11 @@ kickstart.profile.source_on_configuration_file() {
|
||||
grep -q $file $configuration 2>/dev/null || ( echo "[[ -f $profile_d/$file ]] && source $profile_d/$file" >> $configuration )
|
||||
}
|
||||
|
||||
kickstart.profile.location.profile_d() {
|
||||
kickstart.os.is Ubuntu && echo /etc/profile.d
|
||||
kickstart.os.is Mac && echo ~/.profile.d
|
||||
}
|
||||
|
||||
kickstart.profile.location.zsh() {
|
||||
[ `whoami` = root ] && echo /etc/zshenv || echo ~/.zshenv
|
||||
}
|
||||
|
12
lib/kickstart-doc
Executable file
12
lib/kickstart-doc
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
list() {
|
||||
root_dir=`kickstart root-dir`
|
||||
find $root_dir/docs -type f | sed -e 's/.md$//' | cut -c `wc -c <<<$root_dir/docs/`- | tr '/' '.'
|
||||
}
|
||||
|
||||
show() {
|
||||
cat `kickstart root-dir`/docs/$(echo $1 | tr '.' '/').md
|
||||
}
|
||||
|
||||
[ -z "$1" ] && list || show $1
|
Loading…
Reference in New Issue
Block a user