Skip to content

Commit

Permalink
Enable --version flag (#58)
Browse files Browse the repository at this point in the history
* Enable --version flag

Currently, when invoking `gitbuddy --version` you don't get the current version printed. Fortunately, Swift Argument Parser automatically parses that flag if a version argument is provided to the `CommandConfiguration` initializer.

* Reuse VersionCommand.version value

* Remove VersionCommand

* Update Fastfile
  • Loading branch information
MaxDesiatov authored Jul 8, 2020
1 parent 0839c06 commit 368d642
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
9 changes: 8 additions & 1 deletion Sources/GitBuddyCore/Commands/GitBuddy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ import ArgumentParser

/// Entry class of GitBuddy that registers commands and handles execution.
public struct GitBuddy: ParsableCommand {
public static let configuration = CommandConfiguration(commandName: "gitbuddy", abstract: "Manage your GitHub repositories with ease", subcommands: [ChangelogCommand.self, ReleaseCommand.self, VersionCommand.self])
public static let version = "3.0.1"

public static let configuration = CommandConfiguration(
commandName: "gitbuddy",
abstract: "Manage your GitHub repositories with ease",
version: Self.version,
subcommands: [ChangelogCommand.self, ReleaseCommand.self]
)

public init() { }
}
26 changes: 0 additions & 26 deletions Sources/GitBuddyCore/Commands/VersionCommand.swift

This file was deleted.

4 changes: 2 additions & 2 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ desc "Updates the version number to match the releasing tag"
lane :update_version do
tag_name = ENV["BITRISE_GIT_TAG"]

file_path = "../Sources/GitBuddyCore/Commands/VersionCommand.swift"
file_path = "../Sources/GitBuddyCore/Commands/GitBuddy.swift"
text = File.read(file_path)
new_contents = text.gsub(/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(\..*)?/, tag_name)
File.open(file_path, "w") {|file| file.puts new_contents }
end
end

0 comments on commit 368d642

Please sign in to comment.