1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# command_init.py
#
# Copyright (C) 2013 Tim Marston <tim@edm.am>
#
# This file is part of stdhome (hereafter referred to as "this program").
# See http://ed.am/dev/stdhome for more information.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys, os
import getopt
class CommandInit:
def print_help( self ):
print "Usage: " + self.program + " init [URL] [--repo=REPO]"
print
# 01234567890123456789012345678901234567890123456789012345678901234567890123456789
print "Initialise a local repository."
print
print "If an URL is given, the local reposity is a checkout of it (i.e., you can"
print "receive updates from it and changes you commit will be sent to it). The URL"
print "can take the form of a simple hostname, such as \"example.com\", or it can be a"
print "fully-qualified bazaar URL. (Actually, in the first case, where it is a simple"
print "hostname, it is internally expanded to scp://HOSTNAME/~/.stdhome/REPO)."
print
print "Options:"
print " --repo select the repo to check-out or create (defaults to 'home')"
print " --help display help and exit"
exit( 0 )
def run( self, stdhome ):
# parse command line
try:
opts, args = getopt.gnu_getopt(
sys.argv[ 1: ], "",
[ "repo:", "help" ] )
except getopt.GetoptError as e:
stdhome.print_usage( e )
for opt, optargs in opts:
if opt == "--help":
self.print_help()
elif aopt == "--repo":
self.repo = optarg
print "init"
|