Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/tetra/ui/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
module Tetra
# program entry point
class MainCommand < Clamp::Command
option ["-v", "--version"], :flag, "print the version and exit" do
puts Tetra::VERSION
exit(0)
end

subcommand(
"init",
"Inits a tetra project in the current directory",
Expand Down
23 changes: 23 additions & 0 deletions spec/lib/coarse/version_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require "spec_helper"

describe "tetra version flag", type: :aruba do
it "prints the version with --version" do
# Run the command
run_command_and_stop("tetra --version")

# Verify the exit status is 0 (success)
expect(last_command_started).to be_successfully_executed

# Verify the output matches the Ruby constant
expect(last_command_started).to have_output(Tetra::VERSION)
end

it "prints the version with -v" do
run_command_and_stop("tetra -v")

expect(last_command_started).to be_successfully_executed
expect(last_command_started).to have_output(Tetra::VERSION)
end
end