From 1c1e40dad424fc86a35b9038c8bfdf7dd418c8e0 Mon Sep 17 00:00:00 2001 From: Samiul Sk Date: Fri, 7 Nov 2025 18:41:42 +0530 Subject: [PATCH 1/2] feat: add version flag to CLI --- internal/cli/root.go | 9 ++++++--- internal/version/version.go | 21 +++++++++++++++++++++ internal/version/version_test.go | 23 +++++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 internal/version/version.go create mode 100644 internal/version/version_test.go diff --git a/internal/cli/root.go b/internal/cli/root.go index a0dfae2..369ab23 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -2,12 +2,15 @@ package cli import ( "github.com/spf13/cobra" + + "github.com/kernelshard/expose/internal/version" ) var rootCmd = &cobra.Command{ - Use: "expose", - Short: "Expose localhost to the internet", - Long: "Minimal CLI to expose your local dev server", + Use: "expose", + Short: "Expose localhost to the internet", + Long: "Minimal CLI to expose your local dev server", + Version: version.GetFullVersion(), } func Execute() error { diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..10a9b3b --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,21 @@ +package version + +var ( + Version = "v0.1.1" + GitCommit = "4784595" + BuildDate = "2025-11-07" +) + +// GetVersion returns just the version string +func GetVersion() string { + if Version == "dev" { + return "dev (unreleased)" + } + return Version +} + +// GetFullVersion returns version with build metadata (for Cobra) +// Note: Cobra automatically prefixes with "expose version" +func GetFullVersion() string { + return GetVersion() + " (commit: " + GitCommit + ", built: " + BuildDate + ")" +} diff --git a/internal/version/version_test.go b/internal/version/version_test.go new file mode 100644 index 0000000..f46be4f --- /dev/null +++ b/internal/version/version_test.go @@ -0,0 +1,23 @@ +package version + +import ( + "strings" + "testing" +) + +func TestGetVersion(t *testing.T) { + v := GetVersion() + if !strings.Contains(v, Version) { + t.Errorf("GetVersion mismatch expected %s in:%s", Version, v) + } +} + +func TestGetFullVersion(t *testing.T) { + fullVersion := GetFullVersion() + if !strings.Contains(fullVersion, GitCommit) { + t.Errorf("GetFullVersion call expected %s in %s", GitCommit, fullVersion) + } + if !strings.Contains(fullVersion, BuildDate) { + t.Errorf("GetFullVersion call expected %s in %s", BuildDate, fullVersion) + } +} From dcd3b31d50ba0455a6dfb9c318eeb9ada97d70ef Mon Sep 17 00:00:00 2001 From: Samiul Sk Date: Fri, 7 Nov 2025 19:04:27 +0530 Subject: [PATCH 2/2] docs: add LICENSE file, and version flag usage - Add MIT LICENSE file as referenced in README - Document --version flag usage in README --- LICENSE | 21 +++++++++++++++++++++ README.md | 15 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8991c35 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Samiul Sk + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 40bc40f..794d109 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,15 @@ expose tunnel ## 📖 Usage +### Version + +Check the version of expose: + +``` +expose --version +# expose version v0.1.1 (commit: 4784595, built: 2025-11-07) +``` + ### Initialize Project Create a `.expose.yml` configuration file: @@ -129,6 +138,12 @@ Contributions welcome! This project follows: - Commit message format: `type: description` - Clean, tested, documented code +### Contributors + +- **Samiul Sk** - Project creator and maintainer + +*Want to contribute? See our [contributing guidelines](CONTRIBUTING.md) (coming soon)* + ## 📝 License MIT License - see [LICENSE](LICENSE) for details.