Class: Action

Inherits:
Object
  • Object
show all
Defined in:
lib/action.rb

Overview

represents one action to be performed in the shell can assemble a command line from a command and args

Instance Method Summary collapse

Constructor Details

#initialize(config, args, options) ⇒ Action

Returns a new instance of Action.



8
9
10
11
12
# File 'lib/action.rb', line 8

def initialize(config, args, options)
	@config = config
	@args = args
	@options = options
end

Instance Method Details

#alias ⇒ Object



24
25
26
# File 'lib/action.rb', line 24

def alias
	@config["alias"]
end

#command ⇒ Object



28
29
30
# File 'lib/action.rb', line 28

def command
	@config["command"]
end

#load_secrets ⇒ Object



36
37
38
# File 'lib/action.rb', line 36

def load_secrets
	Secrets.new(secrets_file).load
end

#load_secrets? ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/action.rb', line 32

def load_secrets?
	@config["load_secrets"]
end

#run ⇒ Object



14
15
16
17
18
# File 'lib/action.rb', line 14

def run
	load_secrets if load_secrets?

	Kernel.exec(to_s)
end

#secrets_file ⇒ Object



40
41
42
# File 'lib/action.rb', line 40

def secrets_file
	`echo -n #{@options&.dig("secrets", "path")}`
end

#to_s ⇒ Object



20
21
22
# File 'lib/action.rb', line 20

def to_s
	"#{command} #{@args.join(' ')}"
end