diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-03-21 19:37:27 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-03-21 19:37:27 -0300 |
commit | 98f701fb1b82f3e46790adcffb7bba4ae6e7cee8 (patch) | |
tree | df7d4097391db3559caf98928e11101a0a6ec914 | |
parent | 2af113996f556d9606e0a031c287faac56121108 (diff) | |
download | metadot-98f701fb1b82f3e46790adcffb7bba4ae6e7cee8.tar.gz metadot-98f701fb1b82f3e46790adcffb7bba4ae6e7cee8.tar.bz2 |
Enhance documentation and usage
-rw-r--r-- | README.mdwn | 17 | ||||
-rwxr-xr-x | metadot | 41 |
2 files changed, 43 insertions, 15 deletions
diff --git a/README.mdwn b/README.mdwn index 0e3f80a..8ef33d6 100644 --- a/README.mdwn +++ b/README.mdwn @@ -6,7 +6,7 @@ by simply cloning then to your `~/.dotfiles/modules` and renaming a few files. By being modular, it's possible to create modules for specific applications (vim, mutt, emacs, git, etc). By using git submodules or subtrees, one can even -create her own dotfile bundle. +create her own dotfile collection. It was inspired by [holman does dotfiles](https://github.com/holman/dotfiles) and many other initiatives but with a modular design to ease dotfile sharing as @@ -23,10 +23,13 @@ Then check the source integrity of the latest release: /usr/bin/git -C metadot verify-commit HEAD +Note that `/usr/bin/git` is called to avoid any other `git` wrappers or aliases +you might have available on your shell. + Save the metadot repository anywhere but make sure it's available in your `$PATH`. I'm my config I use `~/apps/metadot`. -Then get some modules. You can get the whole standard module bundle with +Then get some modules. You can get the whole standard module collection with metadot clone https://git.fluxo.info/rhatto/dotfiles @@ -34,13 +37,13 @@ Or simply using metadot clone default -Modules names as `dotfiles` have a special meaning and are handled like bundles +Modules names as `dotfiles` have a special meaning and are handled like collections and are cloned directly as `~/.dotfiles`. After cloning, you can check the current dotfiles revision using metadot version -Third-party bundles will hardly suit your needs, so you can fetch individual +Third-party collections will hardly suit your needs, so you can fetch individual modules: metadot clone https://git.fluxo.info/rhatto/dotfiles/vim @@ -51,8 +54,8 @@ Or even start your own: In both cases your `vim` module will be available at `~/.dotfiles/modules/vim`. -You can use just one bundle at a time. While you can mixed a bundle with -individual modules, it's more sane to just start your own bundle and keep +You can use just one collection at a time. While you can mixed a collection with +individual modules, it's more sane to just start your own collection and keep modules as git submodules or subtrees. Usage @@ -70,7 +73,7 @@ Load all modules: metadot load --all -Update a module bundle or all individual modules: +Update a module collection or all individual modules: metadot update @@ -53,7 +53,7 @@ function metadot_backup { } # Find contents of a module -function metadot_find { +function __metadot_find { local module="$1" ( cd $MODULES/$module && find -name '*.link' -or -name '*.dot.link' ) | grep -v '.git/modules' | sed -e 's|./||' } @@ -68,7 +68,7 @@ function metadot_load { echo "Loading module $module..." - for file in `metadot_find $module`; do + for file in `__metadot_find $module`; do echo "Processing $file..." # Get the dirname, replacing string.dot with .string @@ -160,6 +160,11 @@ function metadot_update { # Basic usage function metadot_usage { echo "usage: $BASENAME <option> [arguments]" + echo "" + echo "available actions:" + echo "" + grep "^function metadot_" $0 | cut -d ' ' -f 2 | sed -e 's/metadot_/\t/' -e 's/_/-/g' | sort + echo "" exit 1 } @@ -196,7 +201,7 @@ function metadot_installed { } # Process modules -function metadot_process_modules { +function __metadot_process_modules { if [ -z "$1" ]; then echo "usage: $BASENAME $OPT [module(s)|--all]" fi @@ -217,7 +222,7 @@ function metadot_process_modules { } # Process bundle -function metadot_process_bundle { +function __metadot_process_bundle { local bundle="$1" local dependency local option @@ -265,16 +270,33 @@ function metadot_ls_bundle { cat $DOT/bundles/$bundle } +# Display version +function metadot_version { + ( cd $DOT && git log --show-signature -n 1 ) +} + +# Load a bundle +function metadot_load_bundle { + __metadot_process_bundle $* +} + +# Process bundle dependencies +function metadot_deps_bundle { + __metadot_process_bundle $* +} + # Parsing if [ -z "$OPT" ]; then metadot_usage +elif [ "$OPT" == "usage" ]; then + metadot_usage elif [ "$OPT" == "ls" ]; then metadot_ls elif [ "$OPT" == "ls-bundle" ]; then shift metadot_ls_bundle $* elif [ "$OPT" == "version" ]; then - ( cd $DOT && git log --show-signature -n 1 ) + metadot_version elif [ "$OPT" == "update" ]; then metadot_update elif [ "$OPT" == "backup" ]; then @@ -287,10 +309,13 @@ elif [ "$OPT" == "create" ]; then metadot_create $* elif [ "$OPT" == "load" ] || [ "$OPT" == "deps" ]; then shift - metadot_process_modules $* -elif [ "$OPT" == "load-bundle" ] || [ "$OPT" == "deps-bundle" ]; then + __metadot_process_modules $* +elif [ "$OPT" == "load-bundle" ]; then + shift + metadot_load_bundle $* +elif [ "$OPT" == "deps-bundle" ]; then shift - metadot_process_bundle $* + metadot_deps_bundle $* elif [ "$OPT" == "installed" ]; then metadot_installed fi |