From fb0437f53277543cfd66c388b20cc15c2ad3a50f Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Thu, 18 Sep 2008 22:53:17 +0200 Subject: [PATCH] Command parsing --- pws | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/pws b/pws index 7cc1529..742007a 100755 --- a/pws +++ b/pws @@ -480,13 +480,35 @@ class Ed end end -case ARGV.shift - when 'ls': Ls.new - when 'ed': Ed.new - else - STDERR.puts "What!?" + +def help(code=0, io=STDOUT) + io.puts "Usage: #{$program_name} ed" + io.puts " #{$program_name} ls" + io.puts " #{$program_name} help" + io.puts "Call #{$program_name} --help for additional options/parameters" + exit(code) end + +def parse_command + case ARGV.shift + when 'ls': Ls.new + when 'ed': Ed.new + when 'help': + case ARGV.length + when 0: help + when 1: + ARGV.push "--help" + parse_command + else help(1, STDERR) + end + else + help(1, STDERR) + end +end + +parse_command + # vim:set shiftwidth=2: # vim:set et: # vim:set ts=2: -- 2.39.5