Package caldavclientlibrary :: Package admin :: Package xmlaccounts :: Module manage
[hide private]
[frames] | no frames]

Source Code for Module caldavclientlibrary.admin.xmlaccounts.manage

 1  ## 
 2  # Copyright (c) 2007-2016 Apple Inc. All rights reserved. 
 3  # 
 4  # Licensed under the Apache License, Version 2.0 (the "License"); 
 5  # you may not use this file except in compliance with the License. 
 6  # You may obtain a copy of the License at 
 7  # 
 8  # http://www.apache.org/licenses/LICENSE-2.0 
 9  # 
10  # Unless required by applicable law or agreed to in writing, software 
11  # distributed under the License is distributed on an "AS IS" BASIS, 
12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13  # See the License for the specific language governing permissions and 
14  # limitations under the License. 
15  ## 
16   
17  #import caldavclientlibrary.admin.xmlaccounts.commands 
18  from caldavclientlibrary.admin.xmlaccounts.commands import registered 
19   
20  import sys 
21   
22 -def usage():
23 """ 24 Print out the command line usage. 25 """ 26 cmds = registered.keys() 27 cmds.sort() 28 print """USAGE: manage CMD [OPTIONS] 29 30 CMD: one of: 31 %s 32 33 OPTIONS: specific to each command, use --help with the 34 command to see what options are supported. 35 """ % ("\n".join(["\t%s" % (cmd,) for cmd in cmds]),)
36
37 -def runit():
38 """ 39 Run the command based on command line arguments. 40 """ 41 42 # Dispatch a command based on the first argument 43 if len(sys.argv) == 1: 44 usage() 45 sys.exit(0) 46 47 if registered.has_key(sys.argv[1]): 48 sys.exit(registered[sys.argv[1]]().execute(sys.argv[2:])) 49 else: 50 print "No command called '%s' is available." % (sys.argv[1],) 51 usage() 52 sys.exit(0)
53 54 if __name__ == '__main__': 55 runit() 56