]> gitweb.fluxo.info Git - metadot.git/commitdiff
Enhancing 'update', adding 'clone' and 'create'
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 28 Dec 2013 15:29:40 +0000 (13:29 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 28 Dec 2013 15:29:40 +0000 (13:29 -0200)
README.mdwn
metadot

index b3c0560d7d41259c51256d96d25b56a8649b17b3..0eabca7c35f2e5ad06ee6e364f6b90ca21f2b449 100644 (file)
@@ -8,27 +8,39 @@ By being modular, it's possible to create modules for specific applications
 (vim, mutt, emcas, git, etc). By using git submodules, one can even create her
 own dotfile bundle.
 
-Inspired by [holman does dotfiles](https://github.com/holman/dotfiles) and many
-other initiatives but with a modular design to ease dotfile sharing as the
-`metadot` code is split from the dotfile folder.
+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
+the `metadot` code is split from the dotfile folder.
 
 Instalation
 -----------
 
 Get the code:
 
-    git clone --recursive git://git.sarava.org/metadot.git
+    git clone git://git.sarava.org/metadot.git
 
 Save the metadot repository anywhere but make sure it's available in your `$PATH`.
-Then get some modules. You can get the whole standard module bundle with:
+Then get some modules. You can get the whole standard module bundle with
 
-    git clone --recursive git://git.sarava.org/rhatto/dotfiles.git ~/.dotfiles
+    metadot clone git://git.sarava.org/rhatto/dotfiles.git
 
-This bundle will hardly suit all your needs. You can fetch individual modules or even
-start your own bundle:
+Modules names as `dotfiles` have a special meaning and are handled like bundles
+and are cloned directly as `~/.dotfiles`.
 
-    mkdir -p ~/.dotfiles/modules
-    git clone --recursive git://git.sarava.org/rhatto/dotfiles/vim.git ~/.dotfiles/modules/vim
+Third-party bundled modules will hardly suit your needs, so you can fetch
+individual modules:
+
+    metadot clone git://git.sarava.org/rhatto/dotfiles/vim.git
+
+Or even start your own:
+
+    metadot create vim
+
+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
+modules as git submodules.
 
 Usage
 -----
@@ -45,7 +57,7 @@ Load all modules:
 
     metadot load --all
 
-Update a module bundle:
+Update a module bundle or all individual modules:
 
     metadot update
 
diff --git a/metadot b/metadot
index 47af6ac572ee9e5250a93c0242b0a5cf82968cd6..1736c18a495f1c1e155bf1e86efe789cac412598 100755 (executable)
--- a/metadot
+++ b/metadot
@@ -81,11 +81,40 @@ elif [ "$OPT" == "version" ]; then
   ( cd $DOT && git log -n 1 )
 elif [ "$OPT" == "update" ]; then
   if [ -d "$DOT/.git" ]; then
-    ( cd $DOT && git pull origin master && git submodule update --init )
+    ( cd $DOT && git pull origin master && git submodule update --init --recursive )
+  else
+    for module in `ls $MODULES`; do
+      ( cd $MODULES/$module && git pull origin master && git submodule update --init --recursive )
+    done
   fi
 elif [ "$OPT" == "backup" ]; then
   shift
   metadot_backup $1
+elif [ "$OPT" == "clone" ]; then
+  shift
+  if [ "`basename $1 .git`" == "dotfiles" ]; then
+    metadot_backup $DOT
+    git clone --recursive $1 $DOT
+    echo "Backups saved at $BACKUPS."
+  else
+    mkdir -p $MODULES
+    git clone --recursive $1 $MODULES/`basename $1 .git`
+  fi
+elif [ "$OPT" == "create" ]; then
+  shift
+  mkdir -p $MODULES/$1
+  (
+    cd $MODULES/$1
+    git init
+
+    echo "# $1 dotfile module"                                        > README.mdwn
+    echo ""                                                          >> README.mdwn
+    echo "This is the repository for $1 configuration."              >> README.mdwn
+    echo "More information at https://git.sarava.org/?p=metadot.git" >> README.mdwn
+
+    git add .
+  )
+  echo "Metadot skeleton module $1 created at $MODULES/$1"
 elif [ "$OPT" == "load" ]; then
   shift