Class: Fastlane::Cryptex::CommandsGenerator

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/fastlane/plugin/cryptex/commands_generator.rb

Constant Summary collapse

UI =
FastlaneCore::UI

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.startObject



10
11
12
13
14
15
# File 'lib/fastlane/plugin/cryptex/commands_generator.rb', line 10

def self.start
  FastlaneCore::UpdateChecker.start_looking_for_update('cryptex')
  self.new.run
ensure
  FastlaneCore::UpdateChecker.show_update_status('cryptex', Cryptex::VERSION)
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/fastlane/plugin/cryptex/commands_generator.rb', line 17

def run
  program :version, Cryptex::VERSION
  program :description, "Cryptex"
  program :help, 'Author', 'Helmut Januschka <[email protected]>'
  program :help, 'Website', 'https://fastlane.tools'
  program :help, 'GitHub', 'https://github.com/hjanuschka/fastlane-plugin-cryptex'
  program :help_formatter, :compact

  global_option('--verbose') { $verbose = true }

  FastlaneCore::CommanderGenerator.new.generate(Cryptex::Options.available_options)

  command :run do |c|
    c.syntax = 'cryptex'
    c.description = Cryptex::DESCRIPTION
    c.action do |args, options|
      params = FastlaneCore::Configuration.create(Cryptex::Options.available_options, options.__hash__)
      params.load_configuration_file("Cryptexfile")
      Cryptex::Runner.new.run(params)
    end
  end

  command :init do |c|
    c.syntax = 'cryptex init'
    c.description = 'Create the Cryptexfile for you'
    c.action do |args, options|
      containing = (File.directory?("fastlane") ? 'fastlane' : '.')
      path = File.join(containing, "Cryptexfile")

      if File.exist?(path)
        FastlaneCore::UI.user_error!("You already got a Cryptexfile in this directory")
        return 0
      end

      Cryptex::Setup.new.run(path)
    end
  end

  command :change_password do |c|
    c.syntax = 'cryptex change_password'
    c.description = 'Re-encrypt all files with a different password'
    c.action do |args, options|
      puts "CHANGE PASSWORD"
    end
  end

  command :decrypt do |c|
    c.syntax = "cryptex decrypt"
    c.description = "Decrypts the repository and keeps it on the filesystem"
    c.action do |args, options|
      params = FastlaneCore::Configuration.create(Match::Options.available_options, options.__hash__)
      params.load_configuration_file("Cryptexfile")
      decrypted_repo = Cryptex::GitHelper.clone(params[:git_url], params[:shallow_clone], branch: params[:git_branch], digest: params[:digest])
      UI.success "Repo is at: '#{decrypted_repo}'"
    end
  end
  command "nuke" do |c|
    # We have this empty command here, since otherwise the normal `match` command will be executed
    c.syntax = "cryptex nuke"
    c.description = "Delete all Crypted Files in the repository"
    c.action do |args, options|
      params = FastlaneCore::Configuration.create(Cryptex::Options.available_options, options.__hash__)
      params.load_configuration_file("Cryptexfile")
      params[:type] = "nuke"
      Cryptex::Runner.new.run(params)
    end
  end

  default_command :run

  run!
end