/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/command_init.py

  • Committer: Tim Marston
  • Date: 2014-02-12 21:51:49 UTC
  • Revision ID: tim@ed.am-20140212215149-msaxl7vo98il5i4a
added more commands

Show diffs side-by-side

added added

removed removed

1
 
# init.py
 
1
# command_init.py
2
2
#
3
3
# Copyright (C) 2013 Tim Marston <tim@edm.am>
4
4
#
20
20
 
21
21
 
22
22
import sys, os, re, getopt, shutil, subprocess
23
 
from command import Command
24
 
import stdhome.the as the
25
 
from stdhome.deployment import Deployment
26
 
from stdhome.subprocess import Popen
27
 
 
28
 
 
29
 
class InitCommand( Command ):
 
23
import the
 
24
from deployment import Deployment
 
25
from subprocess import Popen
 
26
 
 
27
 
 
28
class CommandInit:
 
29
 
 
30
 
 
31
        def __init__( self ):
 
32
                self.repo = None
30
33
 
31
34
 
32
35
        def print_help( self ):
57
60
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
58
61
                                        raise the.program.FatalError(
59
62
                                                'invalid repository name: ' + optarg )
60
 
                                the.repo = optarg
 
63
                                self.repo = optarg
61
64
                        elif opt in [ '--verbose', '-v' ]:
62
 
                                the.verbose += 1
 
65
                                the.verbose = True
63
66
                        elif opt == "--help":
64
67
                                self.print_help()
65
68
                
77
80
        def run( self ):
78
81
 
79
82
                # set up repo and check it *doesn't* already exists
 
83
                the.set_repo( self.repo )
80
84
                the.repo.check_dir_exists( False )
81
85
 
82
86
                # ensure our top-level directory exists