Sha256: 4e38b194f15b17be0f12a8afe6beb34e325eaa8d576bf2e053b2b89066889cd1

Contents?: true

Size: 819 Bytes

Versions: 16

Compression:

Stored size: 819 Bytes

Contents

require 'sct_core/ui/ui'
require 'sct_core/config'

module Sct

  class InitCommand

    def execute(args, options)

      dir = SctCore::Config.dir

      cli = HighLine.new

      email = cli.ask("What is your email address?") { |q|
          q.validate = URI::MailTo::EMAIL_REGEXP
      }

      cloud_proxy_path = cli.ask("What is the path of your cloud proxy json credentials?") { |q|
          q.default = "~/.config/gcloud/application_default_credentials.json"
      }

      contents = ""
      contents << "email=#{email}\n"
      contents << "cloud-proxy-path=#{File.expand_path(cloud_proxy_path)}\n"

      if !File.directory?(dir)
          FileUtils.mkdir_p(dir)
      end

      File.write(SctCore::Config.path, contents)

      puts "Generated config file at #{SctCore::Config.path}"
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sct-0.1.35 sct/lib/sct/commands/init.rb
sct-0.1.34 sct/lib/sct/commands/init.rb
sct-0.1.33 sct/lib/sct/commands/init.rb
sct-0.1.31 sct/lib/sct/commands/init.rb
sct-0.1.30 sct/lib/sct/commands/init.rb
sct-0.1.29 sct/lib/sct/commands/init.rb
sct-0.1.28 sct/lib/sct/commands/init.rb
sct-0.1.27 sct/lib/sct/commands/init.rb
sct-0.1.26 sct/lib/sct/commands/init.rb
sct-0.1.25 sct/lib/sct/commands/init.rb
sct-0.1.24 sct/lib/sct/commands/init.rb
sct-0.1.23 sct/lib/sct/commands/init.rb
sct-0.1.22 sct/lib/sct/commands/init.rb
sct-0.1.21 sct/lib/sct/commands/init.rb
sct-0.1.20 sct/lib/sct/commands/init.rb
sct-0.1.19 sct/lib/sct/commands/init.rb