Skip to content

feat: Add --version flag to display version information #87

@lykinsbd

Description

@lykinsbd

Overview

Add a --version flag to display cisshgo version information.

Requirements

Output Format

$ ./cisshgo --version
cisshgo version 1.0.0

Or with build info:

$ ./cisshgo --version
cisshgo version 1.0.0
  commit: abc123def
  built: 2026-03-01T12:00:00Z
  go: go1.26

Implementation

1. Add to CLI Struct

type CLI struct {
    Version       kong.VersionFlag `short:"v" help:"Show version information"`
    Listeners     int              `help:"How many listeners to spawn." default:"50" short:"l" env:"CISSHGO_LISTENERS"`
    // ... rest of fields
}

2. Update Kong Parser

var (
    version = "dev"
    commit  = "none"
    date    = "unknown"
)

func main() {
    kong.Parse(&cli,
        kong.Name("cisshgo"),
        kong.Description("Lightweight SSH server that emulates network equipment for testing."),
        kong.Vars{
            "version": fmt.Sprintf("%s (commit: %s, built: %s)", version, commit, date),
        },
    )
    // ...
}

3. Update GoReleaser

Ensure build-time variables are set in .goreleaser.yml:

builds:
  - ldflags:
      - -s -w
      - -X main.version={{.Version}}
      - -X main.commit={{.Commit}}
      - -X main.date={{.Date}}

Deliverables

  • Add Version field to CLI struct
  • Add version variables (version, commit, date)
  • Update Kong parser with version vars
  • Update .goreleaser.yml with ldflags
  • Test locally: go run -ldflags "-X main.version=dev" cissh.go --version
  • Update documentation with --version flag
  • Add to CLI reference docs

Testing

# Development build
go run -ldflags "-X main.version=dev" cissh.go --version

# Release build (via goreleaser)
./cisshgo --version

Related

  • Part of v1.0.0 release preparation
  • Nice-to-have, not blocking

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions