Sha256: e141e56fc464d6eef3f5ef74b9e2e72d2beaea540354d67e68c5a85639ef3521
Contents?: true
Size: 1.78 KB
Versions: 4
Compression:
Stored size: 1.78 KB
Contents
#!/usr/bin/env ruby require 'rubygems' require 'commander/import' program :name, 'commander' program :version, Commander::VERSION program :description, 'Commander utility program.' command :init do |c| c.syntax = 'commander init <file>' c.summary = 'Initialize a commander template' c.description = 'Initialize an empty <file> with a commander template, allowing very quick creation of commander executables.' c.example 'Create a new file with a commander template.', 'commander init bin/my_executable' c.action do |args, options| file = args.shift || abort('file argument required.') name = ask 'Machine name of program: ' description = ask 'Describe your program: ' commands = ask_for_array 'List the commands you wish to create: ' begin File.open(file, 'w') do |f| f.write <<-"...".gsub!(/^ {10}/, '') #!/usr/bin/env ruby require 'rubygems' require 'commander/import' require '#{name}' program :version, #{name.capitalize}::VERSION program :description, '#{description}' ... commands.each do |command| f.write <<-"...".gsub!(/^ {12}/, '') command :#{command} do |c| c.syntax = '#{name} #{command} [options]' c.summary = '' c.description = '' c.example 'description', 'command example' c.option '--some-switch', 'Some switch that does something' c.action do |args, options| # Do something or c.when_called #{name.capitalize}::Commands::#{command.capitalize} end end ... end end say "Initialized template in #{file}" rescue Exception => e abort e end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
commander-4.1.2 | bin/commander |
commander-4.1.1 | bin/commander |
commander-4.1.0 | bin/commander |
commander-4.0.7 | bin/commander |