{"id":17462872,"url":"https://github.com/nextrevision/fauxcli","last_synced_at":"2025-06-20T15:34:18.349Z","repository":{"id":57654530,"uuid":"59843803","full_name":"nextrevision/fauxcli","owner":"nextrevision","description":"Mocks a command line client from a given YAML file","archived":false,"fork":false,"pushed_at":"2016-11-10T20:05:10.000Z","size":153,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-19T20:42:33.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nextrevision.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-27T15:17:00.000Z","updated_at":"2024-07-22T16:03:36.000Z","dependencies_parsed_at":"2022-09-01T01:21:35.519Z","dependency_job_id":null,"html_url":"https://github.com/nextrevision/fauxcli","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/nextrevision/fauxcli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextrevision%2Ffauxcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextrevision%2Ffauxcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextrevision%2Ffauxcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextrevision%2Ffauxcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nextrevision","download_url":"https://codeload.github.com/nextrevision/fauxcli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextrevision%2Ffauxcli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260970842,"owners_count":23090633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-18T09:10:18.908Z","updated_at":"2025-06-20T15:34:13.337Z","avatar_url":"https://github.com/nextrevision.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fauxcli\n\n[![CircleCI](https://circleci.com/gh/nextrevision/fauxcli.svg?style=svg)](https://circleci.com/gh/nextrevision/fauxcli)\n\nFauxCLI (pronounced foak-ley) mocks a command line client from a given YAML file.\n\n![FauxCLI Example](example.gif)\n\n## Quickstart\n\nInstall:\n\n```\n$ go get github.com/nextrevision/fauxcli\n```\n\nCreate a `cli.yml` file in your current directory (or init one with `FAUXCLI_INIT=1 fauxcli`):\n\n```\nname: spiderpig\nhelp: does whatever a spiderpig does\ncommands:\n  - name: swing\n    help: swings from a web\n    output: |\n      I can't do that, I'm a pig!\n  - name: plop\n    help: super secret maneuver\n    output: |\n      Look out!\n```\n\nRun `fauxcli`:\n\n```\n$ fauxcli\ndoes whatever a spiderpig does\n\nUsage:\n  spiderpig [command]\n\nAvailable Commands:\n  swing       swings from a web\n  plop        super secret maneuver\n\nFlags:\n  -h, --help   help for spiderpig\n\nUse \"spiderpig [command] --help\" for more information about a command.\n```\n\nWith a subcommand:\n\n```\n$ fauxcli swing\nI can't do that, I'm a pig!\n```\n\nAliasing:\n\n```\n$ alias spiderpig='fauxcli'\n$ spiderpig plop\nLook out!\n```\n\n## Installation\n\nWith go:\n\n```\ngo get github.com/nextrevision/fauxcli\n```\n\nUsing GitHub releases:\n\n```\n# OSX\ncurl -s -o /usr/local/bin/fauxcli https://github.com/nextrevision/fauxcli/releases/download/1.1.0/fauxcli_darwin_amd64\n\n# Linux\ncurl -s -o /usr/local/bin/fauxcli https://github.com/nextrevision/fauxcli/releases/download/1.1.0/fauxcli_linux_amd64\n\nchmod +x /usr/local/bin/fauxcli\n```\n\n## `cli.yml`\n\nThe `cli.yml` file holds all the details required in order to mock a CLI application. By default, `fauxcli` will look in your current directory for this file. You can override this setting with the `FAUXCLI_FILE` environment variable pointing to a different YAML file of your choosing.\n\n```\n---\n# (required) name of the command\nname: mycliapp\n\n# (required) the help text for the command (displayed with -h)\nhelp: does something cool\n\n# additional command aliases\naliases: [\"myapp\", \"app\"]\n\n# output to print when the command is run\n# if this key is omitted, the command will act as a\n# parent to any subcommands, essentially doing nothing\n# but printing the help text\noutput: |\n  Hello, World!\n\n# flags available to the command\nflags:\n    # (required) long name of the flag (--debug)\n  - name: debug\n\n    # (required) help text for the flag\n    help: enables debugging\n\n    # short name for the flag (-d)\n    short: d\n\n    # default value of the flag\n    default: false\n\n    # make the flag globally available\n    global: true\n\n    # the type of the value (default string)\n    # available types:\n    #   - string\n    #   - bool\n    #   - int\n    #   - float\n    type: bool\n\n# subcommands (nested from all the options above)\ncommands:\n  - name: subcommand1\n    help: a subcommand\n    flags:\n      - name: upper\n        help: converts output to uppercase\n        short: u\n        type: bool\n    output: |\n      {{ if .Flags.upper.Bool -}}\n      HELLO FROM SC1!\n      {{ else -}}\n      Hello from SC1!\n      {{ end -}}\n  - name: subcommand2\n    help: another subcommand with children\n    commands:\n      - name: child1\n        help: the first child command\n        output: |\n          Hello from child1\n      - name: child2\n        help: the second child command\n        output: |\n          Hello from child2\n```\n\n### Initializing a `cli.yml`\n\nRun fauxcli with the environment variable `FAUXCLI_INIT` set to `1` to create a sample cli.yml.\n\n```\n$ FAXUCLI_INIT=1 fauxcli\nHello, World!\n```\n\n## Output\n\nThe `output` section of a command uses the Golang [template](https://golang.org/pkg/text/template/) syntax (also see [https://gohugo.io/templates/go-templates/](https://gohugo.io/templates/go-templates/)). There are two main variables exposed to you:\n\n1. `Flags`, the list of flags defined in your `cli.yaml`.\n2. `Args`, a list of additional string arguments passed to the command.\n\n### Flags\n\nFlags can be accessed using the following syntax in the output section: `{{ .Flags.flagname }}`. This, however, is not very useful on its own. If you want to retrieve the genericly typed value of a flag, you can use `{{ .Flags.flagname.Value }}`. This is useful for just dumping the value, regardless of type. If you are doing a comparison, like checking if a string flag's value is empty, you need to retrieve the typed value instead, so for a string `{{ .Flags.flagname.String }}`, bools `{{ .Flags.flagname.Bool }}`, ints `{{ .Flags.flagname.Int }}`, and floats `{{ .Flags.flagname.Float }}`.\n\n### Args\n\nAdditional arguments passed to the command can be accessed via the `{{ .Args }}` variable. Useful functions related to args are:\n\n* Checking if args are passed (or empty): `{{ .Args | lengthis 0 }}`\n* Retrieving the first arg: `{{ .Args | first }}`\n* Looping over the args:\n\n```\n{{ range $i, $v := .Args -}}\narg{{ $i }} value: {{ $v }}\n{{ end -}}\n```\n\n### Pipelines/Filters (methods available in functions)\n\nA number of methods are made available to use in the functions, taken primarily from [Pallinder/go-randomdata](https://github.com/Pallinder/go-randomdata#usage) and [leekchan/gtf](https://github.com/leekchan/gtf#reference):\n\n#### Random Data Functions\n\nSometimes is useful to mix up the output type you will receive. Also \"foo\" and \"bar\" get a little boring compared to \"sargentbrindle\" and \"fishhail\". Here are some functions to generate random values in your output templates (from [Pallinder/go-randomdata](https://github.com/Pallinder/go-randomdata#usage)):\n\n| Function | Description | Example | Usage |\n|----------|-------------|---------|-------|\n| name | returns a silly, random, one-word name | Apeflannel | `{{ name }}`|\n| fullname | returns a capitalized, first and last name | Natalie White | `{{ fullname }}` |\n| email | returns a random email address | jaydendavis@example.com | `{{ email }}` |\n| city | returns the name of a random city | Skidaway Island | `{{ city }}` |\n| street | returns the name of a random street | Wilson Ct | `{{ street }}` |\n| address | returns a random street address (two lines) | 48 Lincoln Circle,\\nBurrton, MS, 85910 | `{{ address }}` |\n| number | returns a random number for a given range | 4 | `{{ number 1 10 }}` |\n| paragraph | returns a random paragraph | One dog rolled before him...snip | `{{ paragraph }}` |\n| ipaddress | returns a random IPv4 address | 32.254.96.245 | `{{ ipaddress }}` |\n| day | returns a random day | Sunday | `{{ day }}` |\n| month | returns a random month | November | `{{ month }}` |\n| date | returns a random date | Wednesday 8 Apr 2016 | `{{ date }}` |\n\n\n#### Imported from GTF\n\nAgain, see the [reference here](https://github.com/leekchan/gtf#reference) for additional details.\n\n* replace\n* default\n* length\n* lower\n* upper\n* truncatechars\n* urlencode\n* wordcount\n* divisibleby\n* lengthis\n* trim\n* capfirst\n* pluralize\n* yesno\n* rjust\n* ljust\n* center\n* filesizeformat\n* apnumber\n* intcomma\n* ordinal\n* first\n* last\n* join\n* slice\n* random\n* striptags\n\n#### Custom\n\n| Function | Description | Usage |\n|----------|-------------|-------|\n| string | type casts value as a string | `{{ .Flags.flagname.Value | string }}` |\n| bool | type casts value as a bool | `{{ .Flags.flagname.Value | bool }}` |\n| int | type casts value as a int | `{{ .Flags.flagname.Value | int }}` |\n| float | type casts value as a float (float64) | `{{ .Flags.flagname.Value | float }}` |\n| count | returns an iterator with the specified size | `{{ range $i, $_ := count 3  }}` |\n\n## Examples\n\nCheck out the examples directory for some sample apps.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextrevision%2Ffauxcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextrevision%2Ffauxcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextrevision%2Ffauxcli/lists"}