Commits

Michael Granger committed 9114557

* More work on option-parsing

Comments (0)

Files changed (1)

 require 'logger'
 require 'open3'
 require 'optparse'
+require 'ostruct'
 require 'pathname'
 require 'readline'
 require 'shellwords'
 
 		# If it's a valid command, run it
 		if meth = @command_table[ command ]
-			full_command = @completions[ command ]
+			full_command = @completions[ command ].to_sym
 
 			# If there's a registered optionparser for the command, use it to 
 			# split out options and arguments, then pass those to the command.
 			if oparser = OPTION_PARSERS[ full_command ]
 				self.log.debug "Got an option-parser for #{full_command}."
-				options, args = oparser.parse( args )
-				self.log.debug "  options=%p, args=%p" % [ options, args ]
 
-				meth.call( options, *args )
+				options = OpenStruct.new
+				cmdargs = oparser.parse( args )
+				self.log.debug "  options=%p, args=%p" % [ options, cmdargs ]
+
+				meth.call( options, *cmdargs )
 
 			# ...otherwise just call it with all the args.
 			else
 
 	### List the children of the branch specified by the given +rdn+, or the current branch if none
 	### are specified.
-	def ls_command( *args )
+	def ls_command( options, *args )
 		output = []
 
 		# No argument, just use the current branch
 		output.each do |branch, children|
 			message '', colorize( :cyan ) { branch.dn }
 
-			entries = children.
-				collect {|b| b.rdn }.
-				sort_by {|rdn| rdn.downcase }
-			rows = columnize( entries ).collect do |row|
-				row.gsub( /#{ATTRIBUTE_TYPE}=\s*\S+/ ) do |rdn|
-					format_rdn( rdn )
+			if options.longform
+
+			else
+				entries = children.
+					collect {|b| b.rdn }.
+					sort_by {|rdn| rdn.downcase }
+				rows = columnize( entries ).collect do |row|
+					row.gsub( /#{ATTRIBUTE_TYPE}=\s*\S+/ ) do |rdn|
+						format_rdn( rdn )
+					end
 				end
-			end
 
 			message( *rows )
 		end
 		opts.banner = "ls [OPTIONS] [DNs]"
 
 		opts.on( "-l", "--long", FalseClass, "List in long format." ) do
-			options[:verbose] = v
+			options.longform = true
 		end
 
 	end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.