aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2011-06-04 19:07:13 -0400
committerGravatar Jon Bernard <jbernard@tuxion.com> 2011-06-04 19:07:13 -0400
commit120794b41fcfec0cd92ac67cbec7bf37f90e72e9 (patch)
tree8f25b04e2423e47e4e79adb62961493a9db107c7
parentdd64afd0e3f4ee362471d5e77296eb9109f9e9d6 (diff)
parent0de25186f02b089b024d47414a82351d03c28350 (diff)
downloaddotfiles-120794b41fcfec0cd92ac67cbec7bf37f90e72e9.tar.gz
dotfiles-120794b41fcfec0cd92ac67cbec7bf37f90e72e9.tar.bz2
dotfiles-120794b41fcfec0cd92ac67cbec7bf37f90e72e9.zip
Merge branch 'feature/configfile' into develop
-rw-r--r--README.rst24
-rw-r--r--contrib/dotfilesrc12
-rw-r--r--dotfiles/cli.py40
-rw-r--r--dotfiles/core.py15
4 files changed, 75 insertions, 16 deletions
diff --git a/README.rst b/README.rst
index 6e71871..f8b9f9d 100644
--- a/README.rst
+++ b/README.rst
@@ -4,10 +4,10 @@ Dotfile management made easy
``dotfiles`` is a tool to make managing your dotfile symlinks in ``$HOME``
easy, allowing you to keep all your dotfiles in a single directory.
-Hosting is left to you. Yes, I've seen `<http://dotfiles.org>`_ and I don't
-believe in that model. If you're advanced enough to need dotfile management,
-then you probably already know how you want to host them. Using whatever VCS
-you prefer, or even rsync, you can easily distribute your dotfiles repository
+Hosting is left to you. Yes, I've seen `<http://dotfiles.org>`_ but I don't
+like that model. If you're advanced enough to need dotfile management, then you
+probably already know how you want to host them. Using whatever VCS you
+prefer, or even rsync, you can easily distribute your dotfiles repository
across multiple hosts.
Installation
@@ -51,6 +51,22 @@ To make it available to all your hosts: ::
You get the idea.
+Configuration
+-------------
+
+You can choose to create a configuration file to store personal
+customizations. By default, ``dotfiles`` will look in ``~/.dotfilesrc``. An
+example configuration file might look like: ::
+
+ [dotfiles]
+ repository = ~/Dotfiles
+ ignore = [
+ '.git',
+ '.gitignore']
+ externals = {
+ '.bzr.log': '/dev/null',
+ '.uml': '/tmp'}
+
License
-------
diff --git a/contrib/dotfilesrc b/contrib/dotfilesrc
new file mode 100644
index 0000000..fe1de3e
--- /dev/null
+++ b/contrib/dotfilesrc
@@ -0,0 +1,12 @@
+[dotfiles]
+repository = ~/Dotfiles
+prefix =
+ignore = [
+ '.metadata',
+ '.git',
+ '.gitignore']
+externals = {
+ '.adobe': '/tmp',
+ '.bzr.log': '/dev/null',
+ '.macromedia': '/tmp',
+ '.uml': '/tmp'}
diff --git a/dotfiles/cli.py b/dotfiles/cli.py
index 910dcdc..fadca25 100644
--- a/dotfiles/cli.py
+++ b/dotfiles/cli.py
@@ -2,6 +2,7 @@
import os
from . import core
+import ConfigParser
from optparse import OptionParser, OptionGroup
@@ -13,23 +14,37 @@ def method_list(object):
def parse_args():
parser = OptionParser(usage="Usage: %prog ACTION [OPTION...] [FILE...]")
+ parser.set_defaults(config=os.path.expanduser("~/.dotfilesrc"))
parser.set_defaults(repo=os.path.expanduser("~/Dotfiles"))
+ parser.set_defaults(prefix='')
+ parser.set_defaults(ignore=[])
+ parser.set_defaults(externals={})
+
+ parser.add_option("-C", "--config", type="string", dest="config",
+ help="set configuration file location (default is ~/.dotfilesrc)")
+
parser.add_option("-R", "--repo", type="string", dest="repo",
help="set repository location (default is ~/Dotfiles)")
action_group = OptionGroup(parser, "Actions")
+
action_group.add_option("-a", "--add", action="store_const", dest="action",
const="add", help="add dotfile(s) to the repository")
+
action_group.add_option("-c", "--check", action="store_const",
dest="action", const="check", help="check dotfiles repository")
+
action_group.add_option("-l", "--list", action="store_const",
dest="action", const="list",
help="list currently managed dotfiles")
+
action_group.add_option("-r", "--remove", action="store_const",
dest="action", const="remove",
help="remove dotfile(s) from the repository")
+
action_group.add_option("-s", "--sync", action="store_const",
dest="action", const="sync", help="update dotfile symlinks")
+
parser.add_option_group(action_group)
(opts, args) = parser.parse_args()
@@ -47,5 +62,28 @@ def parse_args():
def main():
+
(opts, args) = parse_args()
- getattr(core.Dotfiles(location=opts.repo), opts.action)(files=args)
+
+ config_defaults = {
+ 'repository': opts.repo,
+ 'prefix': opts.prefix,
+ 'ignore': opts.ignore,
+ 'externals': opts.externals}
+
+ parser = ConfigParser.SafeConfigParser(config_defaults)
+
+ if opts.config:
+
+ parser.read(opts.config)
+
+ if 'dotfiles' in parser.sections():
+ opts.repo = os.path.expanduser(parser.get('dotfiles', 'repository'))
+ opts.prefix = parser.get('dotfiles', 'prefix')
+ opts.ignore = eval(parser.get('dotfiles', 'ignore'))
+ opts.externals = eval(parser.get('dotfiles', 'externals'))
+
+ getattr(core.Dotfiles(location=opts.repo,
+ prefix=opts.prefix,
+ ignore=opts.ignore,
+ externals=opts.externals), opts.action)(files=args)
diff --git a/dotfiles/core.py b/dotfiles/core.py
index 3a60865..b04892f 100644
--- a/dotfiles/core.py
+++ b/dotfiles/core.py
@@ -47,23 +47,16 @@ class Dotfile(object):
class Dotfiles(object):
- IGNORES = ['.metadata', '.git', '.gitignore']
-
- EXTRAS = {'adobe': '/tmp',
- 'bzr.log': '/dev/null',
- 'macromedia': '/tmp',
- 'uml': '/tmp'}
-
- def __init__(self, location):
+ def __init__(self, location, prefix, ignore, externals):
self.location = location
self.dotfiles = []
contents = [x for x in os.listdir(self.location)
- if x not in Dotfiles.IGNORES]
+ if x not in ignore]
for file in contents:
self.dotfiles.append(Dotfile(file,
os.path.join(self.location, file)))
- for file in self.EXTRAS.keys():
- self.dotfiles.append(Dotfile(file, self.EXTRAS[file]))
+ for file in externals.keys():
+ self.dotfiles.append(Dotfile(file, externals[file]))
def list(self, **kwargs):
for dotfile in sorted(self.dotfiles,