Skip to content

Commit

Permalink
Add version to CLI (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-malik authored Jul 24, 2018
1 parent 87197a3 commit 8053ab1
Show file tree
Hide file tree
Showing 6 changed files with 1,143 additions and 876 deletions.
13 changes: 13 additions & 0 deletions Sources/plank/Cli.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum FlagOptions: String {
case indent = "indent"
case lang = "lang"
case help = "help"
case version = "version"

func needsArgument() -> Bool {
switch self {
Expand All @@ -36,6 +37,7 @@ enum FlagOptions: String {
case .onlyRuntime: return false
case .lang: return true
case .help: return false
case .version: return false
case .javaPackageName: return true
}
}
Expand All @@ -52,6 +54,7 @@ extension FlagOptions: HelpCommandOutput {
" --\(FlagOptions.indent.rawValue) - Define a custom indentation",
" --\(FlagOptions.lang.rawValue) - Comma separated list of target language(s) for generating code. Default: \"objc\"",
" --\(FlagOptions.help.rawValue) - Show this text and exit",
" --\(FlagOptions.version.rawValue) - Show version number and exit",
"",
" Objective-C:",
" --\(FlagOptions.objectiveCClassPrefix.rawValue) - The prefix to add to all generated class names",
Expand Down Expand Up @@ -128,6 +131,11 @@ func handleGenerateCommand(withArguments arguments: [String]) {
handleHelpCommand()
return
}

if flags[.version] != nil{
handleVersionCommand()
return
}

let output_dir = flags[.outputDirectory] ?? ""

Expand Down Expand Up @@ -214,3 +222,8 @@ func handleHelpCommand() {

print(helpDocs)
}


func handleVersionCommand() {
print(PLANK_VERSION)
}
1 change: 1 addition & 0 deletions Sources/plank/Version.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let PLANK_VERSION = "1.4.1"
2 changes: 2 additions & 0 deletions docs/_posts/2018-03-10-command-line-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ plank [options] file1 file2 ...
| `indent` | Define a custom indentation width. Default "4" for Objective-C, Java and "2" for Flow |
| `no_recursive` | Only generates files passed in on the commandline (i.e. for `pin.json` only generate `Pin.m` and `Pin.h`) |
| `only_runtime` | Only generates runtime files and exits |
| `no_runtime` | Avoids generating runtime files |
| `help` | Displays usage documentation |
| `version` | Displays version |

## Objective-C

Expand Down
Loading

0 comments on commit 8053ab1

Please sign in to comment.