Class: Rgc::ArgParser
- Inherits:
-
Object
- Object
- Rgc::ArgParser
- Includes:
- GLI::App
- Defined in:
- lib/rgc/arg_parser.rb
Instance Method Summary collapse
- #init_clean ⇒ Object
- #init_encrypt ⇒ Object
- #init_init ⇒ Object
- #init_keygen ⇒ Object
- #init_smudge ⇒ Object
-
#initialize(argv, argf) ⇒ ArgParser
constructor
A new instance of ArgParser.
Constructor Details
#initialize(argv, argf) ⇒ ArgParser
Returns a new instance of ArgParser.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rgc/arg_parser.rb', line 5 def initialize(argv, argf) program_desc 'Program to encrypt certain files inside git repository.' version Rgc::VERSION pre do |global,command,,args| # Pre logic here # Return true to proceed; false to abort and not call the # chosen command # Use skips_pre before a command to skip this block # on that command only true end post do |global,command,,args| # Post logic here # Use skips_post before a command to skip this # block on that command only end on_error do |exception| # Error logic here # return false to skip default error handling puts exception.backtrace true end init_keygen init_init init_encrypt init_clean init_smudge exit run(ARGV) end |
Instance Method Details
#init_clean ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rgc/arg_parser.rb', line 63 def init_clean desc('encrypt content of STDIN and write to STDOUT') command(:clean) do |c| c.action do |, , args| Rgc::Clean.new(, , args) end end end |
#init_encrypt ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rgc/arg_parser.rb', line 85 def init_encrypt desc('set files for encryption') command(:encrypt) do |c| c.flag [:yaml, :y], desc: "yaml values to encrypt" c.action do |, , args| Rgc::Encrypt.new(, , args) end end end |
#init_init ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rgc/arg_parser.rb', line 52 def init_init desc('prepare git repository to use rgc with given key file') command(:init) do |c| c.action do |, , args| Rgc::Init.new(, , args) end end end |