Skip to content

Commit feb4a6f

Browse files
committed
feat: Add version command line argument
1 parent 3a97549 commit feb4a6f

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

lib/tetra/ui/main.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
module Tetra
44
# program entry point
55
class MainCommand < Clamp::Command
6+
option ["-v", "--version"], :flag, "print the version and exit" do
7+
puts Tetra::VERSION
8+
exit(0)
9+
end
10+
611
subcommand(
712
"init",
813
"Inits a tetra project in the current directory",

spec/lib/coarse/version_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
require "spec_helper"
4+
5+
describe "tetra version flag", type: :aruba do
6+
it "prints the version with --version" do
7+
# Run the command
8+
run_command_and_stop("tetra --version")
9+
10+
# Verify the exit status is 0 (success)
11+
expect(last_command_started).to be_successfully_executed
12+
13+
# Verify the output matches the Ruby constant
14+
expect(last_command_started).to have_output(Tetra::VERSION)
15+
end
16+
17+
it "prints the version with -v" do
18+
run_command_and_stop("tetra -v")
19+
20+
expect(last_command_started).to be_successfully_executed
21+
expect(last_command_started).to have_output(Tetra::VERSION)
22+
end
23+
end

0 commit comments

Comments
 (0)