Class: Cardigan::Cli
- Inherits:
-
Object
- Object
- Cardigan::Cli
- Defined in:
- lib/cardigan/cli.rb
Instance Method Summary collapse
- #execute(*args) ⇒ Object
-
#initialize(io = Cardigan::Io.new) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(io = Cardigan::Io.new) ⇒ Cli
Returns a new instance of Cli.
11 12 13 14 15 16 17 |
# File 'lib/cardigan/cli.rb', line 11 def initialize io=Cardigan::Io.new @io = io home_path = File. '~' home = FlatHash::Directory.new FlatHash::Serialiser.new, home_path @local = FlatHash::Directory.new FlatHash::Serialiser.new, '.' @configuration = Cardigan::Configuration.new home, '.cardigan' end |
Instance Method Details
#execute(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cardigan/cli.rb', line 19 def execute *args @configuration['name'] = @io.ask('Enter your full name') unless @configuration['name'] @configuration['email'] = @io.ask('Enter your email address') unless @configuration['email'] repository = FlatHash::Repository.new FlatHash::Serialiser.new, '.cards' name = "\"#{@configuration['name']}\" <#{@configuration['email']}>" local_configuration = Cardigan::Configuration.new @local, '.cardigan' filtered_repository = Cardigan::FilteredRepository.new repository, name, local_configuration workflow_repository = Cardigan::WorkflowRepository.new @local root = Cardigan::RootContext.new @io, filtered_repository, name, workflow_repository if args.size == 0 root.push else root.execute args end end |