pax_global_header00006660000000000000000000000064141766516450014531gustar00rootroot0000000000000052 comment=64044eaacdbcd676cb018d0cd587711377cc6f3f mango-pflag-0.1.0/000077500000000000000000000000001417665164500137175ustar00rootroot00000000000000mango-pflag-0.1.0/.github/000077500000000000000000000000001417665164500152575ustar00rootroot00000000000000mango-pflag-0.1.0/.github/FUNDING.yml000066400000000000000000000000171417665164500170720ustar00rootroot00000000000000github: muesli mango-pflag-0.1.0/.github/dependabot.yml000066400000000000000000000004231417665164500201060ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: "gomod" directory: "/" schedule: interval: "daily" labels: - "dependencies" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" labels: - "dependencies" mango-pflag-0.1.0/.github/workflows/000077500000000000000000000000001417665164500173145ustar00rootroot00000000000000mango-pflag-0.1.0/.github/workflows/build.yml000066400000000000000000000011171417665164500211360ustar00rootroot00000000000000name: build on: [push, pull_request] jobs: build: strategy: matrix: go-version: [~1.12, ^1] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} env: GO111MODULE: "on" steps: - name: Install Go uses: actions/setup-go@v2 with: go-version: ${{ matrix.go-version }} - name: Checkout code uses: actions/checkout@v2 - name: Download Go modules run: go mod download - name: Build run: go build -v ./... - name: Test run: go test ./... mango-pflag-0.1.0/.github/workflows/coverage.yml000066400000000000000000000013211417665164500216270ustar00rootroot00000000000000name: coverage on: [push, pull_request] jobs: coverage: strategy: matrix: go-version: [^1] os: [ubuntu-latest] runs-on: ${{ matrix.os }} env: GO111MODULE: "on" steps: - name: Install Go uses: actions/setup-go@v2 with: go-version: ${{ matrix.go-version }} - name: Checkout code uses: actions/checkout@v2 - name: Coverage env: COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | go test -race -covermode atomic -coverprofile=profile.cov ./... GO111MODULE=off go get github.com/mattn/goveralls $(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github mango-pflag-0.1.0/.github/workflows/lint-soft.yml000066400000000000000000000011731417665164500217600ustar00rootroot00000000000000name: lint-soft on: push: pull_request: permissions: contents: read # Optional: allow read access to pull request. Use with `only-new-issues` option. pull-requests: read jobs: golangci: name: lint-soft runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: # Optional: golangci-lint command line arguments. args: --config .golangci-soft.yml --issues-exit-code=0 # Optional: show only new issues if it's a pull request. The default value is `false`. only-new-issues: true mango-pflag-0.1.0/.github/workflows/lint.yml000066400000000000000000000011011417665164500207760ustar00rootroot00000000000000name: lint on: push: pull_request: permissions: contents: read # Optional: allow read access to pull request. Use with `only-new-issues` option. pull-requests: read jobs: golangci: name: lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: # Optional: golangci-lint command line arguments. #args: # Optional: show only new issues if it's a pull request. The default value is `false`. only-new-issues: true mango-pflag-0.1.0/.gitignore000066400000000000000000000004361417665164500157120ustar00rootroot00000000000000# Binaries for programs and plugins *.exe *.exe~ *.dll *.so *.dylib # Test binary, built with `go test -c` *.test # Output of the go coverage tool, specifically when used with LiteIDE *.out # Dependency directories (remove the comment below to include it) # vendor/ example/example mango-pflag-0.1.0/.golangci-soft.yml000066400000000000000000000012701417665164500172540ustar00rootroot00000000000000run: tests: false issues: include: - EXC0001 - EXC0005 - EXC0011 - EXC0012 - EXC0013 max-issues-per-linter: 0 max-same-issues: 0 linters: enable: # - dupl - exhaustive # - exhaustivestruct - goconst - godot - godox - gomnd - gomoddirectives - goprintffuncname - ifshort # - lll - misspell - nakedret - nestif - noctx - nolintlint - prealloc - wrapcheck # disable default linters, they are already enabled in .golangci.yml disable: - deadcode - errcheck - gosimple - govet - ineffassign - staticcheck - structcheck - typecheck - unused - varcheck mango-pflag-0.1.0/.golangci.yml000066400000000000000000000006051417665164500163040ustar00rootroot00000000000000run: tests: false issues: include: - EXC0001 - EXC0005 - EXC0011 - EXC0012 - EXC0013 max-issues-per-linter: 0 max-same-issues: 0 linters: enable: - bodyclose - exportloopref - goimports - gosec - nilerr - predeclared - revive - rowserrcheck - sqlclosecheck - tparallel - unconvert - unparam - whitespace mango-pflag-0.1.0/LICENSE000066400000000000000000000020671417665164500147310ustar00rootroot00000000000000MIT License Copyright (c) 2022 Christian Muehlhaeuser 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 OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. mango-pflag-0.1.0/README.md000066400000000000000000000021651417665164500152020ustar00rootroot00000000000000# mango-pflag [![Latest Release](https://img.shields.io/github/release/muesli/mango-pflag.svg)](https://github.com/muesli/mango-pflag/releases) [![Build Status](https://github.com/muesli/mango-pflag/workflows/build/badge.svg)](https://github.com/muesli/mango-pflag/actions) [![Go ReportCard](https://goreportcard.com/badge/muesli/mango-pflag)](https://goreportcard.com/report/muesli/mango-pflag) [![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://pkg.go.dev/github.com/muesli/mango-pflag) pflag adapter for [mango](https://github.com/muesli/mango). ## Example ```go import ( "fmt" "github.com/muesli/mango" mpflag "github.com/muesli/mango-pflag" "github.com/muesli/roff" flag "github.com/spf13/pflag" ) func main() { flag.Parse() manPage := mango.NewManPage(1, "mango", "a man-page generator"). WithLongDescription("mango is a man-page generator for Go."). WithSection("Copyright", "(C) 2022 Christian Muehlhaeuser.\n"+ "Released under MIT license.") flag.VisitAll(mpflag.PFlagVisitor(manPage)) fmt.Println(manPage.Build(roff.NewDocument())) } ``` mango-pflag-0.1.0/example/000077500000000000000000000000001417665164500153525ustar00rootroot00000000000000mango-pflag-0.1.0/example/main.go000066400000000000000000000015161417665164500166300ustar00rootroot00000000000000package main import ( "fmt" "github.com/muesli/mango" mpflag "github.com/muesli/mango-pflag" "github.com/muesli/roff" flag "github.com/spf13/pflag" ) var ( one = flag.String("one", "", "first value") //nolint two = flag.String("two", "", "second value") //nolint ) func main() { flag.Parse() manPage := mango.NewManPage(1, "mango", "a man-page generator"). WithLongDescription("mango is a man-page generator for the Go flag, pflag, and cobra packages.\n"+ "Features:\n"+ "* User-friendly\n"+ "* Plugable"). WithSection("Authors", "mango was written by Christian Muehlhaeuser "). WithSection("Copyright", "Copyright (C) 2022 Christian Muehlhaeuser.\n"+ "Released under MIT license.") flag.VisitAll(mpflag.PFlagVisitor(manPage)) fmt.Println(manPage.Build(roff.NewDocument())) } mango-pflag-0.1.0/go.mod000066400000000000000000000002311417665164500150210ustar00rootroot00000000000000module github.com/muesli/mango-pflag go 1.17 require ( github.com/muesli/mango v0.1.0 github.com/muesli/roff v0.1.0 github.com/spf13/pflag v1.0.5 ) mango-pflag-0.1.0/go.sum000066400000000000000000000007531417665164500150570ustar00rootroot00000000000000github.com/muesli/mango v0.1.0 h1:DZQK45d2gGbql1arsYA4vfg4d7I9Hfx5rX/GCmzsAvI= github.com/muesli/mango v0.1.0/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4= github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8= github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= mango-pflag-0.1.0/mpflag.go000066400000000000000000000012211417665164500155100ustar00rootroot00000000000000package mpflag import ( "github.com/muesli/mango" "github.com/spf13/pflag" ) // PFlagVisitor is used to visit all flags and track them in a mango.ManPage. func PFlagVisitor(m *mango.ManPage) func(*pflag.Flag) { return func(f *pflag.Flag) { _ = m.Root.AddFlag(mango.Flag{ Name: f.Name, Short: f.Shorthand, Usage: f.Usage, PFlag: true, }) } } // PFlagCommandVisitor is used to visit all flags and track them in a mango.Command. func PFlagCommandVisitor(c *mango.Command) func(*pflag.Flag) { return func(f *pflag.Flag) { _ = c.AddFlag(mango.Flag{ Name: f.Name, Short: f.Shorthand, Usage: f.Usage, PFlag: true, }) } }