Skip to content

Commit

Permalink
Relax ACON::Application version to accept any String (#419)
Browse files Browse the repository at this point in the history
* Default to `UNKNOWN` as we do not want to assume semver anymore
* Update `framework` integration to not try to still pass a `SemanticVersion`
  • Loading branch information
Blacksmoke16 authored Jun 5, 2024
1 parent 1e7bb34 commit 10e5e98
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
4 changes: 4 additions & 0 deletions spec/application_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ struct ApplicationTest < ASPEC::TestCase
ACON::Application.new("foo", "1.2.3").long_version.should eq "foo <info>1.2.3</info>"
end

def test_long_version_non_semver : Nil
ACON::Application.new("foo", "2024.1.2").long_version.should eq "foo <info>2024.1.2</info>"
end

def test_help : Nil
ACON::Application.new("foo", "1.2.3").help.should eq "foo <info>1.2.3</info>"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/list_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ListCommandTest < ASPEC::TestCase
tester.execute command: "list", decorated: false

tester.display(true).should eq normalize <<-OUTPUT
foo 0.1.0
foo UNKNOWN
Usage:
command [options] [arguments]
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/applications/descriptor2.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class DescriptorApplication2 < ACON::Application
def initialize
super "My Athena application", SemanticVersion.new 1, 0, 0
super "My Athena application", "1.0.0"

self.add DescriptorCommand1.new
self.add DescriptorCommand2.new
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/text/application_1.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foo <info>0.1.0</info>
foo <info>UNKNOWN</info>

<comment>Usage:</comment>
command [options] [arguments]
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/text/application_run1.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foo 0.1.0
foo UNKNOWN

Usage:
command \[options\] \[arguments\]
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/text/application_run4.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
foo 0.1.0
foo UNKNOWN
9 changes: 2 additions & 7 deletions src/application.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require "semantic_version"
require "levenshtein"

# A container for a collection of multiple `ACON::Command`, and serves as the entry point of a CLI application.
Expand All @@ -25,7 +24,7 @@ require "levenshtein"
# override the array of default commands, or customize the default input options, etc.
class Athena::Console::Application
# Returns the version of this CLI application.
getter version : SemanticVersion
getter version : String

# Returns the name of this CLI application.
getter name : String
Expand Down Expand Up @@ -96,11 +95,7 @@ class Athena::Console::Application
@terminal : ACON::Terminal
@wants_help : Bool = false

def self.new(name : String, version : String = "0.1.0") : self
new name, SemanticVersion.parse version
end

def initialize(@name : String, @version : SemanticVersion = SemanticVersion.new(0, 1, 0))
def initialize(@name : String, @version : String = "UNKNOWN")
@terminal = ACON::Terminal.new

# TODO: Emit events when certain signals are triggered.
Expand Down
1 change: 1 addition & 0 deletions src/athena-console.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "ecr"
require "semantic_version"

require "athena-clock"

Expand Down

0 comments on commit 10e5e98

Please sign in to comment.