Revisions
-
rtomayko revised this gist
Oct 18, 2014 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,10 +14,10 @@ # parse arguments file = __FILE__ ARGV.options do |opts| opts.on("-f", "--flag") { flag = true } opts.on("-o", "--opt=val", String) { |val| option = val } opts.on("-i", "--int=val", Integer) { |val| integer = val } opts.on("--list=[x,y,z]", Array) { |val| list = val } opts.on_tail("-h", "--help") { exec "grep ^#/<'#{file}'|cut -c4-" } opts.parse! end -
rtomayko revised this gist
Sep 3, 2011 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,15 +12,13 @@ list = ["x", "y", "z"] # parse arguments file = __FILE__ ARGV.options do |opts| opts.on("-f", "--flag") { |flag| } opts.on("-o", "--opt=val", String) { |option| } opts.on("-i", "--int=val", Integer) { |integer| } opts.on("--list=[x,y,z]", Array) { |list| } opts.on_tail("-h", "--help") { exec "grep ^#/<'#{file}'|cut -c4-" } opts.parse! end -
rtomayko revised this gist
Sep 3, 2011 . 1 changed file with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,6 @@ option = "default value" integer = 23 list = ["x", "y", "z"] # parse arguments ARGV.options do |opts| @@ -26,8 +25,8 @@ end # do your thing warn "ARGV: #{ARGV.inspect}" warn "flag: #{flag.inspect}" warn "option: #{option.inspect}" warn "integer: #{integer.inspect}" warn "list: #{list.join(',')}" -
rtomayko revised this gist
Sep 3, 2011 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ #/ Usage: <progname> [options]... #/ How does this script make my life easier? # ** Tip: use #/ lines to define the --help usage message. $stderr.sync = true require 'optparse' # default options -
rtomayko revised this gist
Sep 3, 2011 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ #!/usr/bin/env ruby #/ Usage: <progname> [options]... #/ How does this script make my life easier? # ** Tip: use #/ lines to define the --help usage message. require 'optparse' -
rtomayko revised this gist
Sep 3, 2011 . 1 changed file with 8 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ #!/usr/bin/env ruby #/ Usage: <progname> [options]... #/ How does this script make my life easier? #/ # ** Tip: use #/ lines to define the --help usage message. require 'optparse' # default options @@ -16,7 +18,10 @@ opts.on("-o", "--opt=val", String) { |option| } opts.on("-i", "--int=val", Integer) { |integer| } opts.on("--list=[x,y,z]", Array) { |list| } opts.on_tail("-h", "--help") do puts File.read(__FILE__).grep(/^#\//).map {|line| line[3...-1]}.join("\n") exit end opts.parse! end @@ -25,4 +30,4 @@ warn "flag: #{flag.inspect}" warn "option: #{option.inspect}" warn "integer: #{integer.inspect}" warn "list: #{list.join(',')}" -
rtomayko created this gist
Sep 3, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/usr/bin/env ruby #/ Usage: <progname> [options]... #/ How does this program make my life easier? require 'optparse' # default options flag = false option = "default value" integer = 23 list = ["x", "y", "z"] dest = File.expand_path(File.dirname($0)) # parse arguments ARGV.options do |opts| opts.on("-f", "--flag") { |flag| } opts.on("-o", "--opt=val", String) { |option| } opts.on("-i", "--int=val", Integer) { |integer| } opts.on("--list=[x,y,z]", Array) { |list| } opts.on_tail("-h", "--help") { exit } opts.parse! end # do your thing warn "arguments: #{ARGV}" warn "flag: #{flag.inspect}" warn "option: #{option.inspect}" warn "integer: #{integer.inspect}" warn "list: #{list.join(',')}"