123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #!/bin/bash
- # ~/bin/example
- . <(ffoom init)
- ffoo import core
-
- #
- # basic echo helpers
- #
- think "about saying something..." # thinks loud if FFOO_VERBOSE
- warn "this is just an example" # obvious :)
- false || die "false was true!" # Perlism :)
- x=1; y=2; z=3
- debug "x='$x'" "y='$y'" "z='$z'" # debug:example: x='1'
- # debug:example: y='2'
- # debug:example: z='3'
- debug -v x y z # << short for ^
- echo "hello" | debug_pipe mypipe # debug|mypipe|: hello
- warn -f should_be_empty # warns with name+content
- # unless the file is empty
- myfun() {
- num=42
- debug -v num
- }
- myfun # debug:myfun: num='42'
-
-
- #
- # more advanced functions
- #
- mkdir $HOME/.cfg
- cat >$HOME/.cfg/foo.ini <<EOF
- # a sample ini file
- [foo]
- multiline = also possible
- multiline = like this :)
- [foo.bar]
- baz = qux
- baz2 = public qux
- [py]
- s1 =#!/usr/bin/python
- s1 =def main():
- s1 = print "will work!"
- EOF
- ffoo import ini
- FFOO_INI_PATH=$HOME/.cfg
- iniread -s foo.bar -k baz foo.ini # prints "qux"
- iniread -p foo.bar.baz foo.ini # ...short for above
- iniread -p foo.bar.baz # ...even shorter
- iniread -S -p py.s1 > s1.py foo.ini # the -S will preserve spaces on RHS so
- python s1.py # << will work
-
-
- #
- # including runtime ini merging
- #
- mkdir $HOME/.cfg/private
- cat >$HOME/.cfg/private/foo.ini <<EOF
- # private extension to above
- [foo.bar]
- baz2 = secret qux!
- # this approach can make it easier
- # to sync private info separately
- EOF
- FFOO_INI_PATH=$HOME/.cfg:$HOME/.cfg-private
- iniread -p foo.bar.baz2 # merges both paths -- prints 2 lines
- iniread -1 -p foo.bar.baz2 # ... last one wins -- prints "secret..."
- iniread -S foo.ini # merges both files verbatim
-
-
- #
- # even more
- #
- ffoo import flow
- wait_until -e ! test -e badfile # -e means use eval (make "!" work)
- think "the badfile is away..."
- bad_file_away() { # but you can avoid eval
- ! test -f badfile
- }
- wait_until bad_file_away
-
- #
- # ... and more
- #
- ffoo import testing
- register_artifact future.log # does not need to exist yet
- myprog > future.log
- collect_artifacts # will preserve tree from /
- # and produce folder called e.g.
- # artifacts-20140915-141502
-
-
- #
- # ...AND MORE!
- #
- ffoo import sw
- cat > deps.ini <<EOF
- [needs.now]
- yum = ronn
- yum = vim
- pypi = docopt
- [needs.for_test]
- cpan = Test::More
- # yeah I made that up
- EOF
- iniread -s needs.now ./deps.ini | any_install
- iniread -s needs.for_test ./deps.ini | any_install
|