Class: RubynCode::CLI::Commands::Budget
- Inherits:
-
Base
- Object
- Base
- RubynCode::CLI::Commands::Budget
show all
- Defined in:
- lib/rubyn_code/cli/commands/budget.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
aliases, all_names, hidden?
Class Method Details
.command_name ⇒ Object
7
|
# File 'lib/rubyn_code/cli/commands/budget.rb', line 7
def self.command_name = '/budget'
|
.description ⇒ Object
8
|
# File 'lib/rubyn_code/cli/commands/budget.rb', line 8
def self.description = 'Show or set session budget (/budget [amount])'
|
Instance Method Details
#execute(args, ctx) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/rubyn_code/cli/commands/budget.rb', line 10
def execute(args, ctx)
amount = args.first
if amount
ctx.renderer.info("Session budget set to $#{amount}")
{ action: :set_budget, amount: amount.to_f }
else
remaining = ctx.budget_enforcer.remaining_budget
ctx.renderer.info("Remaining budget: $#{format('%.4f', remaining)}")
end
end
|