Author: dmacvicar Date: Fri Oct 12 17:34:13 2007 New Revision: 7505 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7505&view=rev Log: skeleton for main repotool entry point Added: trunk/repotools/repotool.rb Added: trunk/repotools/repotool.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/repotools/repotool.rb?rev=7505&am... ============================================================================== --- trunk/repotools/repotool.rb (added) +++ trunk/repotools/repotool.rb Fri Oct 12 17:34:13 2007 @@ -0,0 +1,58 @@ +# == Synopsis +# +# hello: greets user, demonstrates command line parsing +# +# == Usage +# +# hello [OPTION] ... command +# +# global options: +# +# -h, --help: +# show help +# +# create: creates a repository +# +# --input x, -i x: +# Uses x as input. x is another repository of the supported types +# +# --name [name]: +# greet user by name, if name not supplied default is John +# +# command: The directory in which to issue the greeting. + +require 'logger' +require 'getoptlong' +require 'rdoc/usage' + +opts = GetoptLong.new( + [ '--help', '-h', GetoptLong::NO_ARGUMENT ], + [ '--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT ], + [ '--input', '-i', GetoptLong::REQUIRED_ARGUMENT ], + [ '--name', GetoptLong::OPTIONAL_ARGUMENT ] +) + +opts.each do |opt, arg| + case opt + when '--help' + RDoc::usage + when '--input' + puts "input #{arg}" + when '--repeat' + repetitions = arg.to_i + when '--name' + if arg == '' + name = 'John' + else + name = arg + end + end +end + +if ARGV.length != 1 + puts "Missing command argument (try --help)" + exit 0 +end + +dir = ARGV.shift + -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org