Sha256: 691e9c1d411e6db2922bbc1c36e911481d390523aa1e7a25b9993080d53ad4dd
Contents?: true
Size: 1.38 KB
Versions: 5
Compression:
Stored size: 1.38 KB
Contents
require 'sct/command_interface' require 'highline' module Sct class InitCommand IS_PUBLIC_COMMAND = true SYNTAX = 'sct init' SUMMARY = 'Initialize a base configuration file for sct' EXAMPLE = 'sct init' EXAMPLE_DESCRIPTION = 'sct init will create a configuration file' DESCRIPTION = "sct init will create a configuration file" OPTIONS = [] def initialize end def execute(args, options) Sct::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" } host_path = "/etc/hosts" if Sct::Config.operatingSystem == Sct::Config::WINDOWS host_path = "/mnt/c/Windows/System32/drivers/etc/hosts" end contents = "" contents << "email=#{email}\n" contents << "cloud-proxy-path=#{File.expand_path(cloud_proxy_path)}\n" contents << "host-path=#{File.expand_path(host_path)}\n" if !File.directory?(Sct::Config.dir) FileUtils.mkdir_p(Sct::Config.dir) end File.write(Sct::Config.path, contents) puts "Generated config file at #{Sct::Config.path}" end implements CommandInterface end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
sct-0.1.11 | lib/sct/commands/init.rb |
sct-0.1.10 | lib/sct/commands/init.rb |
sct-0.1.9 | lib/sct/commands/init.rb |
sct-0.1.8 | lib/sct/commands/init.rb |
sct-0.1.7 | lib/sct/commands/init.rb |