-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd/gno): add gno version command (#3002)
<!-- please provide a detailed description of the changes made in this pull request. --> I've added the `version` command to gno to get the version of gno that is installed <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests </details> --------- Co-authored-by: Morgan <[email protected]>
- Loading branch information
Showing
5 changed files
with
64 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/gnolang/gno/gnovm/pkg/version" | ||
"github.com/gnolang/gno/tm2/pkg/commands" | ||
) | ||
|
||
// newVersionCmd creates a new version command | ||
func newGnoVersionCmd(io commands.IO) *commands.Command { | ||
return commands.NewCommand( | ||
commands.Metadata{ | ||
Name: "version", | ||
ShortUsage: "version", | ||
ShortHelp: "display installed gno version", | ||
}, | ||
nil, | ||
func(_ context.Context, args []string) error { | ||
io.Println("gno version:", version.Version) | ||
return nil | ||
}, | ||
) | ||
} |
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,32 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gnolang/gno/gnovm/pkg/version" | ||
) | ||
|
||
func TestVersionApp(t *testing.T) { | ||
originalVersion := version.Version | ||
|
||
t.Cleanup(func() { | ||
version.Version = originalVersion | ||
}) | ||
|
||
versionValues := []string{"chain/test4.2", "develop", "master"} | ||
|
||
testCases := make([]testMainCase, len(versionValues)) | ||
for i, v := range versionValues { | ||
testCases[i] = testMainCase{ | ||
args: []string{"version"}, | ||
stdoutShouldContain: "gno version: " + v, | ||
} | ||
} | ||
|
||
for i, testCase := range testCases { | ||
t.Run(versionValues[i], func(t *testing.T) { | ||
version.Version = versionValues[i] | ||
testMainCaseRun(t, []testMainCase{testCase}) | ||
}) | ||
} | ||
} |
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,3 @@ | ||
package version | ||
|
||
var Version = "develop" |