{"id":15096013,"url":"https://github.com/bettercallshao/kwt","last_synced_at":"2025-04-14T22:12:56.624Z","repository":{"id":45157800,"uuid":"228271610","full_name":"bettercallshao/kwt","owner":"bettercallshao","description":"Run commands easily.","archived":false,"fork":false,"pushed_at":"2024-12-11T23:52:40.000Z","size":150,"stargazers_count":19,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T10:11:42.406Z","etag":null,"topics":["automation","business-solutions","cli","full-stack","gin-gonic","golang","gorilla","metaprogramming","template","websocket","workflow","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bettercallshao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-16T00:14:41.000Z","updated_at":"2024-08-09T07:43:18.000Z","dependencies_parsed_at":"2024-02-07T06:28:51.920Z","dependency_job_id":"c2e6d75f-a07f-40de-8597-11f19518ec2a","html_url":"https://github.com/bettercallshao/kwt","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bettercallshao%2Fkwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bettercallshao%2Fkwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bettercallshao%2Fkwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bettercallshao%2Fkwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bettercallshao","download_url":"https://codeload.github.com/bettercallshao/kwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968916,"owners_count":21191162,"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":["automation","business-solutions","cli","full-stack","gin-gonic","golang","gorilla","metaprogramming","template","websocket","workflow","yaml"],"created_at":"2024-09-25T15:44:52.939Z","updated_at":"2025-04-14T22:12:56.592Z","avatar_url":"https://github.com/bettercallshao.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kwt\n[![Release](https://img.shields.io/github/release/bettercallshao/kwt.svg)](https://github.com/bettercallshao/kwt/releases/latest)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](/LICENSE.md)\n[![CircleCI](https://circleci.com/gh/bettercallshao/kwt.svg?style=shield)](https://circleci.com/gh/bettercallshao/kwt)\n\nRun commands easily.\n\n* [What is it](#what-is-it)\n* [Installation](#installation)\n* [Quick start](#quick-start)\n* [Web interface](#web-interface)\n* [Develop](#develop)\n* [Further info](#further-info)\n\n## What is it\n\nKwt reads from a repository of YAMLs of templated commands, and enables the user to render and execute the commands with arguments provided at run-time. It can help to\n* Avoid re-typing long commands over and over for routine tasks.\n* Version control and share commands.\n\n## Installation\n\nLinux \u0026 Mac through [Homebrew](https://brew.sh/).\n```\nbrew install bettercallshao/tap/kwt\n```\n\nWindows through [Scoop](https://scoop.sh/).\n```\nscoop bucket add bettercallshao https://github.com/bettercallshao/scoop-bucket\nscoop install bettercallshao/kwt\n```\n\nOr download latest zip from [releases](https://github.com/bettercallshao/kwt/releases), extract, and put the binary files on your system path.\n\n## Quick start\n\nKick start by ingesting the demo menus.\n```\nkwt i -s https://raw.githubusercontent.com/bettercallshao/kwt-menus/master/python-demo.yaml\nkwt i -s https://raw.githubusercontent.com/bettercallshao/kwt-menus/master/developer-demo.yaml\n```\n\nSee a list of commands by running `kwt h`.\n```\nNAME:\n   kwt - Run commands easily.\n\nUSAGE:\n   kwt [global options] command [command options] [arguments...]\n\nVERSION:\n   v0.5.2-20201123005537\n\nCOMMANDS:\n   start, s           Starts executor for a menu\n   ingest, i          Ingests menu locally from a source\n   developer-demo, d  Developer commands for demo\n   python-demo, p     Python commands for demo\n   help, h            Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n   --help, -h     show help (default: false)\n   --version, -v  print the version (default: false)\n```\n* `start`, `ingest`, `help`, `--help`, `--version` are global arguments.\n* `python-demo` and `developer-demo` are command definitions.\n\nCheck what is in `python-demo` by `kwt p -h`.\n```\nNAME:\n   kwt python-demo - Python commands for demo\n\nUSAGE:\n   kwt python-demo command [command options] [arguments...]\n\nCOMMANDS:\n   uuid, u                 Generate a UUID\n   forex-rate, f           Print forex rates\n   mortgage-calculator, m  Calculate mortgage payment\n   bit-expander, b         Convert between decimal, hex, and bit representations\n   csv-to-markdown, c      Convert a CSV to markdown table\n   help, h                 Shows a list of commands or help for one command\n\nOPTIONS:\n   --help, -h     show help (default: false)\n   --version, -v  print the version (default: false)\n```\n\nCheck what `forex-rate` does with `kwt p f -h`.\n```\nNAME:\n   kwt python-demo forex-rate - Print forex rates\n\nUSAGE:\n   kwt python-demo forex-rate [command options] [arguments...]\n\nOPTIONS:\n   --base value, -b value     Base currency (default: \"USD\")\n   --symbols value, -s value  Comma separated currency symbol list (default: \"CAD,GBP\")\n   --dry, -d                  render command but don't run (default: false)\n   --help, -h                 show help (default: false)\n```\n* `--dry`, `--help` are flags defined by `kwt`.\n* `--base`, `--symbols` are input arguments, with default values.\n\nLets try EUR to JPY and AUD.\n```\n$ kwt p f -b EUR -s JPY,AUD\nOn 2020-11-13\n1 EUR can buy 123.88 JPY\n1 EUR can buy 1.63 AUD\n```\n\nUse the `--dry` flag to see what actually ran.\n```\n$ kwt p f -b EUR -s AUD -d\ntemplate: python3 -u -c \"\nimport urllib.request\nimport urllib.parse\nimport json\n\nurl = 'https://api.exchangeratesapi.io/latest?base={{.base}}\u0026symbols={{.symbols}}'\nr = json.load(urllib.request.urlopen(url))\n\ndate = r['date']\nrates = r['rates']\n\nprint(f'On {date}')\nprint('\\n'.join(\n  f'1 {{.base}} can buy {rates[symbol]:.2f} {symbol}'\n  for symbol in rates\n))\n\"\n\nrendered: python3 -u -c \"\nimport urllib.request\nimport urllib.parse\nimport json\n\nurl = 'https://api.exchangeratesapi.io/latest?base=EUR\u0026symbols=AUD'\nr = json.load(urllib.request.urlopen(url))\n\ndate = r['date']\nrates = r['rates']\n\nprint(f'On {date}')\nprint('\\n'.join(\n  f'1 EUR can buy {rates[symbol]:.2f} {symbol}'\n  for symbol in rates\n))\n\"\n```\n\nFirst the command template was printed, then the command rendered with input arguments. The command is defined in `$HOME/.kwt/python-demo.yaml`.\n```yaml\nname: python-demo\nversion: v0.1.0\nhelp: Python commands for demo\nactions:\n- name: forex-rate\n  help: Print forex rates\n  template: |\n    python3 -u -c \"\n    import urllib.request\n    import urllib.parse\n    import json\n\n    url = 'https://api.exchangeratesapi.io/latest?base={{.base}}\u0026symbols={{.symbols}}'\n    r = json.load(urllib.request.urlopen(url))\n\n    date = r['date']\n    rates = r['rates']\n\n    print(f'On {date}')\n    print('\\n'.join(\n      f'1 {{.base}} can buy {rates[symbol]:.2f} {symbol}'\n      for symbol in rates\n    ))\n    \"\n  params:\n  - name: base\n    help: Base currency\n    value: USD\n  - name: symbols\n    help: Comma separated currency symbol list\n    value: CAD,GBP\n```\n\nAdd to this file or create more YAMLs in `$HOME/.kwt/` to add more commands. If some commands should only be available locally in a specific cwd, add the YAML in `$CWD/.kwt/`.\n\n## Web interface\n\nKwt can also be run in conjunction with kwtd to give a web based user interface to the menus. Kwtd is installed as part of the kwt package and runs without arguments.\n```\n[kwtd] 2020/11/24 01:42:01 version: v0.5.2-20201123005537\n[kwtd] 2020/11/24 01:42:01 starting kwtd ...\n[kwtd] 2020/11/24 01:42:01 listening on http://127.0.0.1:7171\n```\n\nIt is recommended to install kwtd as a start up service for convenience with the official helper menus.\n\nFor Windows (see help for more commands).\n```\nkwt i -s https://raw.githubusercontent.com/bettercallshao/kwt-menus/master/windows-kwtd.yaml\nkwt windows-kwtd startup-add\n```\n\nFor Mac (see help for more commands).\n```\nkwt i -s https://raw.githubusercontent.com/bettercallshao/kwt-menus/master/mac-kwtd.yaml\nkwt mac-kwtd startup-add\n```\n\nOnce kwtd is running, visit [http://127.0.0.1:7171](http://127.0.0.1:7171) in browser to find three sections.\n* Channels - each channel is a placeholder for a kwt executor to connect to. If visited without active connection, it shows a blank message.\n* Menus - each available menu can be viewed as a JSON.\n* Ingestion - ingesting menus same as kwt.\n\nAs an example, we will run the `csv-to-markdown` command in the web interface. First open a terminal (with python3 available) and connect a kwt executor to kwtd (on channel 0 by default) declaring the `python-demo` menu.\n```\nkwt s -m python-demo\n```\n\nLogs are printed and the command should block and occupy the terminal. Now visit channel 0 on the page, click on `csv-to-markdown`, copy the following into the `data` param, press execute, then toggle markdown to render it.\n```\nName,Icon,Website\nFacebook,[![Website shields.io](https://img.shields.io/website-up-down-green-red/http/shields.io.svg)](),https://facebook.com/\nTwitter,[![Website shields.io](https://img.shields.io/website-up-down-green-red/http/shields.io.svg)](),https://twitter.com/home\n```\n\n![Drag Racing](https://i.imgur.com/hQcheIU.gif)\n\n## Develop\n\nTo build, install golang and run `make`. The CI is powered by [GoReleaser](https://goreleaser.com/) and CircleCI.\n\n## Further info\n\nI wrote a blog series on kwt https://bettercallshao.com/tag/kwt/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbettercallshao%2Fkwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbettercallshao%2Fkwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbettercallshao%2Fkwt/lists"}