]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
added global --yes option
authorelijah <elijah@riseup.net>
Thu, 7 Feb 2013 08:38:50 +0000 (00:38 -0800)
committerelijah <elijah@riseup.net>
Thu, 7 Feb 2013 08:38:50 +0000 (00:38 -0800)
lib/leap_cli/commands/deploy.rb
lib/leap_cli/commands/node.rb
lib/leap_cli/commands/pre.rb
lib/leap_cli/commands/project.rb

index c2f98b8cc54b681f6386add54cf8fc827b95ad26..337ef4dc908bcd43a53e8d8d170f245097c15028 100644 (file)
@@ -15,13 +15,13 @@ module LeapCli
       c.arg_name 'TAG[,TAG]'
       c.flag :tags
 
-      c.action do |global_options,options,args|
+      c.action do |global,options,args|
         init_submodules
 
         nodes = manager.filter!(args)
         if nodes.size > 1
           say "Deploying to these nodes: #{nodes.keys.join(', ')}"
-          unless agree "Continue? "
+          if !global[:yes] && !agree("Continue? ")
             quit! "OK. Bye."
           end
         end
index 6a60c4549045684118c04321da12e07b0867eda5..da29a020ca6787f4a47aad494ec8fa0de97a055c 100644 (file)
@@ -45,12 +45,12 @@ module LeapCli; module Commands
     node.arg_name '<node-filter>' #, :optional => false, :multiple => false
     node.command :init do |init|
       init.switch 'echo', :desc => 'If set, passwords are visible as you type them (default is hidden)', :negatable => false
-      init.action do |global_options,options,args|
+      init.action do |global,options,args|
         assert! args.any?, 'You must specify a node-filter'
         finished = []
         manager.filter(args).each_node do |node|
           ping_node(node)
-          save_public_host_key(node)
+          save_public_host_key(node, global)
           update_compiled_ssh_configs
           ssh_connect(node, :bootstrap => true, :echo => options[:echo]) do |ssh|
             ssh.install_authorized_keys
@@ -133,7 +133,7 @@ module LeapCli; module Commands
   #
   # see `man sshd` for the format of known_hosts
   #
-  def save_public_host_key(node)
+  def save_public_host_key(node, global)
     log :fetching, "public SSH host key for #{node.name}"
     public_key = get_public_key_for_ip(node.ip_address, node.ssh.port)
     pub_key_path = Path.named_path([:node_ssh_pub_key, node.name])
@@ -154,7 +154,7 @@ module LeapCli; module Commands
       say("Type        -- #{public_key.bits} bit #{public_key.type.upcase}")
       say("Fingerprint -- " + public_key.fingerprint)
       say("Public Key  -- " + public_key.key)
-      if !agree("Is this correct? ")
+      if !global[:yes] && !agree("Is this correct? ")
         bail!
       else
         puts
index 26dce403eb7cecff639c8c679b72f847dc53b261..f10eb684a078b3fe3ca7adad034283342c0fdc18 100644 (file)
@@ -18,6 +18,9 @@ module LeapCli
     desc 'Display version number and exit'
     switch :version, :negatable => false
 
+    desc 'Skip prompts and assume "yes"'
+    switch :yes, :negatable => false
+
     pre do |global,command,options,args|
       #
       # set verbosity
index 12d159bb7ecc960e9041c2df7cb3edd45e3e8634..fc3972fec8cc603afafa73ebba0fbe4301bfa5a3 100644 (file)
@@ -9,7 +9,7 @@ module LeapCli; module Commands
     c.flag 'name', :desc => "The name of the provider", :default_value => 'Example'
     c.flag 'domain', :desc => "The primary domain of the provider", :default_value => 'example.org'
     c.flag 'platform', :desc => "File path of the leap_platform directory", :default_value => '../leap_platform'
-    c.action do |global_options, options, args|
+    c.action do |global, options, args|
       directory = args.first
       unless directory && directory.any?
         help! "Directory name is required."
@@ -18,7 +18,7 @@ module LeapCli; module Commands
       unless File.exists?(directory)
         bail! { log :missing, "directory #{directory}" }
       end
-      create_initial_provider_files(directory, options)
+      create_initial_provider_files(directory, global, options)
     end
   end
 
@@ -29,7 +29,7 @@ module LeapCli; module Commands
   #
   # creates new provider directory
   #
-  def create_initial_provider_files(directory, options)
+  def create_initial_provider_files(directory, global, options)
     Path.set_provider_path(directory)
     Dir.chdir(directory) do
       assert_files_missing! 'provider.json', 'common.json', 'Leapfile', :base => directory
@@ -37,7 +37,7 @@ module LeapCli; module Commands
       platform_dir = File.expand_path(options[:platform])
 
       unless File.symlink?(platform_dir) || File.directory?(platform_dir)
-        if agree("The platform directory \"#{options[:platform]}\" does not exist.\nDo you want me to create it by cloning from the\ngit repository #{DEFAULT_REPO}? ")
+        if global[:yes] || agree("The platform directory \"#{options[:platform]}\" does not exist.\nDo you want me to create it by cloning from the\ngit repository #{DEFAULT_REPO}? ")
           assert_bin! 'git'
           ensure_dir platform_dir
           Dir.chdir(platform_dir) do