Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add create command for CLI closes #1

  • Loading branch information...
commit 18b3a0c44554e3daf1b0070977a8b453c5bd3153 1 parent abd9c09
@achiu authored
Showing with 28 additions and 0 deletions.
  1. +18 −0 lib/consular/cli.rb
  2. +10 −0 spec/cli_spec.rb
View
18 lib/consular/cli.rb
@@ -116,6 +116,24 @@ def edit(project = nil)
open_in_editor path, options[:editor]
end
+ # Create a Termfile in the current or specified directory
+ #
+ # @example
+ #
+ # # create Termfile in current directory
+ # Consular::CLI.start ['create']
+ # # create Termfile in /tmp
+ # Consular::CLI.start ['create', '-r=/tmp']
+ #
+ # @api public
+ desc "create", "create a Termfile in directory"
+ method_option :root, :type => :string, :default => '.', :aliases => '-r'
+ method_option :editor, :type => :string, :default => nil, :aliases => '-e'
+ method_option :capture, :type => :boolean, :default => false, :aliases => '-c'
+ def create
+ invoke :edit, [], options
+ end
+
# Delete the global script or Termfile
#
# @param [String] project
View
10 spec/cli_spec.rb
@@ -227,6 +227,16 @@ def setup!; puts('setup'); end
assert_match /setup/, File.read('/tmp/Termfile')
end
+ it "alias create" do
+ FakeFS.deactivate!
+ Consular::CLI.any_instance.expects(:open_in_editor).with('/tmp/Termfile', nil).returns(true)
+ output = capture_io { Consular::CLI.start ['create', '-r=/tmp'] }.join('')
+
+ assert_match /create/, output
+ assert_match /Termfile/, output
+ assert_match /setup/, File.read('/tmp/Termfile')
+ end
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.