Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix links to examples #34

Merged
merged 5 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Flags based on structures. [![GoDoc](https://godoc.org/github.com/octago/sflags?status.svg)](http://godoc.org/github.com/octago/sflags) [![Build Status](https://travis-ci.org/octago/sflags.svg?branch=master)](https://travis-ci.org/octago/sflags) [![codecov](https://codecov.io/gh/octago/sflags/branch/master/graph/badge.svg)](https://codecov.io/gh/octago/sflags) [![Go Report Card](https://goreportcard.com/badge/github.com/octago/sflags)](https://goreportcard.com/report/github.com/octago/sflags)
# Flags based on structures [![GoDoc](https://godoc.org/github.com/octago/sflags?status.svg)](http://godoc.org/github.com/octago/sflags) [![Build Status](https://travis-ci.org/octago/sflags.svg?branch=master)](https://travis-ci.org/octago/sflags) [![codecov](https://codecov.io/gh/octago/sflags/branch/master/graph/badge.svg)](https://codecov.io/gh/octago/sflags) [![Go Report Card](https://goreportcard.com/badge/github.com/octago/sflags)](https://goreportcard.com/report/github.com/octago/sflags)

The sflags package uses structs, reflection and struct field tags
to allow you specify command line options. It supports [different types](#supported-types-in-structures) and [features](#features).
Expand All @@ -21,14 +21,28 @@ type Config struct {

And you can use your favorite flag or cli library!

## Supported flags and cli libraries:
## Supported libraries and features:

- [x] [flag](https://golang.org/pkg/flag/) - [example](https://github.com/octago/sflags/blob/master/examples/flag/main.go)
- [x] [spf13/pflag](https://github.com/spf13/pflag) - [example](https://github.com/octago/sflags/blob/master/examples/pflag/main.go)
- [x] [spf13/cobra](https://github.com/spf13/cobra) - [example](https://github.com/octago/sflags/blob/master/examples/cobra/main.go)
- [ ] [spf13/viper](https://github.com/spf13/viper)
- [x] [urfave/cli](https://github.com/urfave/cli) [example](https://github.com/octago/sflags/blob/master/examples/urfave_cli/main.go)
- [x] [kingpin](https://github.com/alecthomas/kingpin) [example](https://github.com/octago/sflags/blob/master/examples/kingpin/main.go)
| | | Hidden | Deprecated | Short | Env |
| --- | --- | ------ | ---------- |------ | --- |
| <ul><li>[x] [flag]</li><ul> | [example](./examples/flag/main.go) | `-` | `-` | `-` | `-` |
| <ul><li>[x] [kingpin]</li></ul> | [example](./examples/kingpin/main.go) | <ul><li>[x] </li></ul> | <ul><li>[ ] </li></ul> | <ul><li>[x] </li></ul> | <ul><li>[x] </li></ul> |
| <ul><li>[x] [spf13/pflag]</li></ul> | [example](./examples/pflag/main.go) | <ul><li>[x] </li></ul> | <ul><li>[x] </li></ul> | <ul><li>[x] </li></ul> | `-` |
| <ul><li>[x] [spf13/cobra]</li></ul> | [example](./examples/cobra/main.go) | <ul><li>[x] </li></ul> | <ul><li>[x] </li></ul> | <ul><li>[x] </li></ul> | `-` |
| <ul><li>[ ] [spf13/viper]</li><ul> | | <ul><li>[ ] </li></ul> | <ul><li>[ ] </li></ul> | <ul><li>[ ] </li></ul> | <ul><li>[ ] </li></ul> |
| <ul><li>[x] [urfave/cli]</li></ul> | [example](./example/urfave_cli/main.go) | <ul><li>[x] </li></ul> | `-` | <ul><li>[x] </li></ul> | <ul><li>[x] </li></ul> |

- [x] - feature is supported and implemented

`-` - feature can't be implemented for this cli library


[flag]: https://golang.org/pkg/flag/
[spf13/pflag]: https://github.com/spf13/pflag
[spf13/cobra]: https://github.com/spf13/cobra
[spf13/viper]: https://github.com/spf13/viper
[urfave/cli]: https://github.com/urfave/cli
[kingpin]: https://github.com/alecthomas/kingpin

## Features:

Expand Down Expand Up @@ -74,22 +88,10 @@ And you can use your favorite flag or cli library!
- [ ] url list
- [ ] units (bytes 1kb = 1024b, speed, etc)

## Supported features matrix:
## Example:

| Name | Hidden | Deprecated | Short | Env |
| --- | --- | --- | --- | --- |
| flag | - | - | - | - |
| pflag | [x] | [x] | [x] | - |
| kingpin | [x] | [ ] | [x] | [x] |
| urfave | [x] | - | [x] | [x] |
| cobra | [x] | [x] | [x] | - |
| viper | [ ] | [ ] | [ ] | [ ] |

\[x] - feature is supported and implemented

`-` - feature can't be implemented for this cli library

Simple example for flag library:
The code below shows how to use `sflags` with the [flag] library. Examples for other
flag libraries are available from [./examples](./examples) dir.

```golang
package main
Expand Down Expand Up @@ -145,8 +147,6 @@ Usage of _obj/exe/main:
exit status 2
```

Look at the other [examples](https://github.com/octago/sflags/blob/master/examples) for different flag libraries.

## Options for flag tag

The flag default key string is the struct field name but can be specified in the struct field's tag value.
Expand Down