Add doc function

This commit is contained in:
Bruno Tavares 2014-02-21 19:30:18 -03:00
parent 246ae7051e
commit 460fdd57f8
3 changed files with 38 additions and 6 deletions

View File

@ -108,6 +108,26 @@ Using alternate ssh port
kickstart bootstrap "-p 2222 vagrant@vagrant" 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 ### Thanks
This project was inspired on [sunzi](https://github.com/kenn/sunzi) This project was inspired on [sunzi](https://github.com/kenn/sunzi)

View File

@ -2,7 +2,7 @@ kickstart.profile.add_to_profile() {
local file=$1 local file=$1
[ ! -f files/$file ] && kickstart.info "File files/$file not found" && exit 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 mkdir -p $profile_d
cp files/$file $profile_d/$file 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.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() { kickstart.profile.source_on_configuration_file() {
local file=$1 local file=$1
local profile_d=$2 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 ) 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() { kickstart.profile.location.zsh() {
[ `whoami` = root ] && echo /etc/zshenv || echo ~/.zshenv [ `whoami` = root ] && echo /etc/zshenv || echo ~/.zshenv
} }

12
lib/kickstart-doc Executable file
View 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