-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Brian McGee <[email protected]>
- Loading branch information
1 parent
d4ab015
commit d53f98e
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package build | ||
|
||
var ( | ||
Name = "treefmt" | ||
Version = "v0.0.1+dev" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"git.numtide.com/numtide/treefmt/build" | ||
"git.numtide.com/numtide/treefmt/cli" | ||
"github.com/alecthomas/kong" | ||
) | ||
|
||
func main() { | ||
// This is to maintain compatibility with 1.0.0 which allows specifying the version with a `treefmt --version` flag | ||
// on the 'default' command. With Kong it would be better to have `treefmt version` so it would be treated as a | ||
// separate command. As it is, we would need to weaken some of the `existingdir` and `existingfile` checks kong is | ||
// doing for us in the default format command. | ||
for _, arg := range os.Args { | ||
if arg == "--version" || arg == "-V" { | ||
fmt.Printf("%s %s\n", build.Name, build.Version) | ||
return | ||
} | ||
} | ||
|
||
ctx := kong.Parse(&cli.Cli) | ||
ctx.FatalIfErrorf(ctx.Run()) | ||
} |