Skip to content

Runnable examples

Prerequisites

To play with the examples:

  1. Clone the repository:
    gh repo clone mszostok/version
    
  2. Navigate to the examples directory.
  3. Run a chosen example.

Cobra

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.buildDate=`date`'" -o example ./cobra

# Try out
./example version -h
./example version

Cobra Upgrade Notice

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.version=0.6.0'" -o example ./upgrade-notice

# Try out
./example version
./example version -ojson

Printer Upgrade Notice

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.version=0.6.0'" -o example ./upgrade-notice-custom

# Try out
./example version

Upgrade Notice sub-command

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.version=0.6.0'" -o example ./upgrade-notice-sub-cmd

# Try out
./example

Standalone Upgrade Notice

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.version=0.6.0'" -o example ./upgrade-notice-standalone

# Try out
./example version check

Custom Fields

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.buildDate=`date`'" -o example ./custom-fields

# Try out
./example

Printer

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.buildDate=`date`'" -o example ./printer

# Try out
./example
./example -oyaml
./example version -oshort

Printer Post Hook

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.version=0.6.0'" -o example ./printer-post-hook

# Try out
./example

Plain

Run in terminal

# Build
go build  -ldflags "-X 'go.szostok.io/version.buildDate=`date`'" -o example ./plain

# Try out
./example

Custom Formatting

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.buildDate=`date`'" -o example ./custom-formatting

# Try out
./example

Custom Layout

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.buildDate=`date`'" -o example ./custom-layout

# Try out
./example

Custom Style from environment variable

Run in terminal

# Build
export CLI_STYLE="${PWD}/style.yaml"
go build -ldflags "-X 'go.szostok.io/version.buildDate=`date`'" -o example ./custom-layout

# Try out
./example

Custom Renderer

Run in terminal

# Build
go build -ldflags "-X 'go.szostok.io/version.buildDate=`date`'" -o example ./custom-renderer

# Try out
./example
Back to top