{"id":13483273,"url":"https://github.com/piotrmurach/tty","last_synced_at":"2025-05-14T04:07:30.028Z","repository":{"id":4867038,"uuid":"6021947","full_name":"piotrmurach/tty","owner":"piotrmurach","description":"Toolkit for developing sleek command line apps.","archived":false,"fork":false,"pushed_at":"2022-12-31T11:46:26.000Z","size":4756,"stargazers_count":2519,"open_issues_count":13,"forks_count":80,"subscribers_count":44,"default_branch":"master","last_synced_at":"2025-05-12T07:43:46.701Z","etag":null,"topics":["cli","cli-app","ruby-cli","ruby-gem","terminal","tty-components"],"latest_commit_sha":null,"homepage":"https://ttytoolkit.org","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Skookum/nodealytics","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piotrmurach.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"piotrmurach"}},"created_at":"2012-09-30T20:21:06.000Z","updated_at":"2025-05-08T11:39:59.000Z","dependencies_parsed_at":"2023-01-13T13:16:29.748Z","dependency_job_id":null,"html_url":"https://github.com/piotrmurach/tty","commit_stats":null,"previous_names":["peter-murach/tty"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrmurach%2Ftty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrmurach%2Ftty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrmurach%2Ftty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrmurach%2Ftty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piotrmurach","download_url":"https://codeload.github.com/piotrmurach/tty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254069121,"owners_count":22009492,"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":["cli","cli-app","ruby-cli","ruby-gem","terminal","tty-components"],"created_at":"2024-07-31T17:01:09.586Z","updated_at":"2025-05-14T04:07:29.986Z","avatar_url":"https://github.com/piotrmurach.png","language":"Ruby","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://ttytoolkit.org\"\u003e\u003cimg width=\"130\" src=\"https://github.com/piotrmurach/tty/blob/master/images/tty.png\" alt=\"TTY Toolkit logo\"/\u003e\u003c/a\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\n[![Gem Version](https://badge.fury.io/rb/tty.svg)][gem]\n[![Actions CI](https://github.com/piotrmurach/tty/workflows/CI/badge.svg?branch=master)][gh_actions_ci]\n[![Build status](https://ci.appveyor.com/api/projects/status/0a85w6yr40lmuo3o?svg=true)][appveyor]\n[![Maintainability](https://api.codeclimate.com/v1/badges/b7656caaf3bdb1fd4c04/maintainability)][codeclimate]\n[![Test Coverage](https://api.codeclimate.com/v1/badges/b7656caaf3bdb1fd4c04/test_coverage)][coverage]\n[![Inline docs](http://inch-ci.org/github/piotrmurach/tty.svg?branch=master)][inchpages]\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]\n\n[gem]: http://badge.fury.io/rb/tty\n[gh_actions_ci]: https://github.com/piotrmurach/tty/actions?query=workflow%3ACI\n[appveyor]: https://ci.appveyor.com/project/piotrmurach/tty\n[codeclimate]: https://codeclimate.com/github/piotrmurach/tty/maintainability\n[coverage]: https://codeclimate.com/github/piotrmurach/tty/test_coverage\n[inchpages]: http://inch-ci.org/github/piotrmurach/tty\n[gitter]: https://gitter.im/piotrmurach/tty\n\n\u003e TTY is a toolbox for developing beautiful command line clients in Ruby with a fluid interface for gathering input, querying terminal properties and displaying information.\n\n## Motivation\n\nAll too often libraries that interact with terminals create their own interface logic that gathers input from users and displays information back. Many times utility files are created that contain methods for reading system or terminal properties. Shouldn't we focus our energy on building the actual client?\n\nBuilding terminal tools takes time. I believe that modular components put together in a single package with project scaffolding will help people build things faster and produce higher quality results. It is easy to jump start a new project with available scaffolding and mix and match components to create new tooling.\n\n## Features\n\n* Jump-start development of your command line app the Unix way with scaffold provided by [teletype](#2-bootstrapping).\n* Fully modular, choose out of many [components](#3-components) to suit your needs or use any 3rd party ones.\n* All tty components are small packages that do one thing well.\n* Fully tested with major ruby interpreters.\n\n## Installation\n\nAdd this line to your application's Gemfile to install all components:\n\n    gem 'tty'\n\nor install a particular component:\n\n    gem 'tty-*'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install tty\n\n## Contents\n\n* [1. Overview](#1-overview)\n* [2. Bootstrapping](#2-bootstrapping)\n  * [2.1 new command](#21-new-command)\n    * [2.1.1 --author, -a flag](#211---author--a-flag)\n    * [2.1.2 --ext flag](#212---ext-flag)\n    * [2.1.3 --license, -l flag](#213---license--l-flag)\n    * [2.1.4 --test, -t flag](#214---test--t-flag)\n  * [2.2 add command](#22-add-command)\n    * [2.2.1 --args flag](#221---args-flag)\n    * [2.2.2 --desc flag](#222---desc-flag)\n    * [2.2.3 --force flag](#223---desc-flag)\n  * [2.3 Working with Commands](#23-working-with-commands)\n  * [2.4 Arguments](#24-arguments)\n  * [2.5 Description](#25-description)\n  * [2.6 Options and Flags](#26-options-and-flags)\n  * [2.7 Global Flags](#27-global-flags)\n  * [2.8 Working with Subcommands](#28-working-with-subcommands)\n* [3. Components](#3-components)\n* [4. Contributing](#4-contributing)\n\n## 1. Overview\n\n**TTY** provides you with commands and many components to get you onto the path of building awesome terminal applications in next to no time.\n\nTo simply jump start a new command line application use `teletype` executable:\n\n```bash\n$ teletype new app\n```\n\nMove in to your new app, and then add more commands:\n\n```bash\n$ cd app\n$ teletype add config\n```\n\nThroughout the rest of this guide, I will assume a generated application called `app`, that you are in the working directory of 'app/', and a newly created bare command `config`.\n\n## 2. Bootstrapping\n\n### 2.1 `new` command\n\nRunning `teletype new [app-name]` will bootstrap an entire project file structure based on the bundler `gem` command setup enhanced by additional files and folders related to command application development.\n\nFor example, to create a new command line application called `app` do:\n\n```ruby\n$ teletype new app\n```\n\nThe output will contain all the files that have been created during setup:\n\n```\nCreating gem 'app'\n    create app/Gemfile\n    create app/.gitignore\n    create app/lib/app.rb\n    create app/lib/app/version.rb\n    ...\n```\n\nIn turn, the following files and directories will be generated in the `app` folder familiar to anyone who has created a gem beforehand:\n\n```\n▾ app/\n├── ▾ exe/\n│   └── app\n├── ▾ lib/\n│   ├── ▾ app/\n│   │   ├── ▸ commands/\n│   │   ├── ▸ templates/\n│   │   ├── cli.rb\n│   │   ├── command.rb\n│   │   └── version.rb\n│   └── app.rb\n├── CODE_OF_CONDUCT.md\n├── Gemfile\n├── LICENSE.txt\n├── README.md\n├── Rakefile\n└── app.gemspec\n```\n\nBy convention the file `lib/app/cli.rb` provides the main entry point to your command line application:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    # Error raised by this runner\n    Error = Class.new(StandardError)\n\n    desc 'version', 'app version'\n    def version\n      require_relative 'version'\n      puts \"v#{App::VERSION}\"\n    end\n    map %w(--version -v) =\u003e :version\n  end\nend\n```\n\nThis is where all your application commands and subcommands will be defined.\n\nTeletype uses `Thor` as an option parsing library by directly inheriting from it.\n\nAnd also by convention the `start` method is used to parse the command line arguments inside the `app` executable:\n\n```ruby\nApp::CLI.start\n```\n\nRun the new command with `--help` or `-h` flag to see all available options:\n\n```ruby\n$ teletype new --help\n$ teletype new -h\n```\n\nExecute `teletype` to see all available commands.\n\n#### 2.1.1 `--author`, `-a` flag\n\nThe `teletype` generator can inject name into documentation for you:\n\n```bash\n$ teletype new app --author 'Piotr Murach'\n```\n\n#### 2.1.2 `--ext` flag\n\nTo specify that `teletype` should create a binary executable (as `exe/GEM_NAME`) in the generated project use the `--ext` flag. This binary will also be included in the `GEM_NAME.gemspec` manifest. This is disabled by default, to enable do:\n\n```bash\n$ teletype new app --ext\n```\n\n#### 2.1.3 `--license`, `-l` flag\n\nThe `teletype` generator comes prepackaged with most popular open source licenses:\n`agplv3`, `apache`, `bsd2`, `bsd3`, `gplv2`, `gplv3`, `lgplv3`, `mit`, `mplv2`, `custom`. By default the `mit` license is used. To change that do:\n\n```ruby\n$ teletype new app --license bsd3\n```\n\n#### 2.1.4 `--test`, `-t` flag\n\nThe `teletype` comes configured to work with `rspec` and `minitest` frameworks which are the only two acceptable values. The `GEM_NAME.gemspec` will be configured and appropriate testing directory setup. By default the `RSpec` framework is used.\n\n```ruby\n$ teletype new app --test=minitest\n$ teletype new app -t=minitest\n```\n\n### 2.2 `add` command\n\nOnce application has been initialized, you can create additional command by using `teletype add [command-name]` task:\n\n```ruby\n$ teletype add config\n$ teletype add create\n```\n\nThis will add `create.rb` and `config.rb` commands to the CLI client:\n\n```\n▾ app/\n├── ▾ commands/\n│   ├── config.rb\n│   └── create.rb\n├── ▸ templates/\n│   ├── ▸ config/\n│   └── ▸ create/\n├── command.rb\n├── cli.rb\n└── version.rb\n```\n\nThen you will be able to call the new commands like so:\n\n```ruby\n$ app config\n$ app create\n```\n\nThe commands require you to specify the actual logic in their `execute` methods.\n\nPlease note that command names should be provided as `camelCase` or `snake_case`. For example:\n\n```\n$ teletype add addConfigCommand   # =\u003e correct\n$ teletype add add_config_command # =\u003e correct\n$ teletype add add-config-command # =\u003e incorrect\n```\n\n#### 2.2.1 `--args` flag\n\nYou can specify that `teletype` should add a command with a variable number of arguments using the `--args` flag. The `--args` flag accepts space delimited variable names. To specify required argument use a string name, for an optional argument pass `name = nil` enclosed in quote marks and any variable number of arguments needs to be preceded by asterisk:\n\n```bash\n$ teletype add config --args name           # required argument\n$ teletype add config --args \"name = nil\"   # optional argument\n$ teletype add config --args *names         # variadic argument\n```\n\nFor more in-depth usage see [2.4 Arguments](#24-arguments).\n\n#### 2.2.2 `--desc` flag\n\nEvery generated command will have a default description 'Command description...', however whilst generating a command you can and should specify a custom description to provide more context with `--desc` flag:\n\n```bash\n$ teletype add config --desc 'Set and get configuration options'\n```\n\nFor more in-depth usage see [2.5 Description](#25-description).\n\n#### 2.2.3 `--force` flag\n\nIf you wish to overwrite currently implemented command use `--force` flag:\n\n```bash\n$ teletype add config --force\n```\n\n### 2.3 Working with Commands\n\nRunning\n\n```\nteletype add config\n```\n\na new command `config` will be added to `commands` folder creating the following files structure inside the `lib` folder:\n\n```shell\n▾ app/\n├── ▾ commands/\n│   └── config.rb\n├── ▾ templates/\n│   └── ▸ config/\n├── cli.rb\n├── command.rb\n└── version.rb\n```\n\nThe `lib/app/cli.rb` file will contain generated command entry which handles the case where the user asks for the `config` command help or invokes the actual command:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    desc 'config', 'Command description...'\n    def config(*)\n      if options[:help]\n        invoke :help, ['config']\n      else\n        require_relative 'commands/config'\n        App::Commands::Config.new(options).execute\n      end\n    end\n  end\nend\n```\n\nAnd the `lib/app/commands/config.rb` will allow you to specify all the command logic. In the `Config` class which by convention matches the command name, the `execute` method provides a place to implement the command logic:\n\n```ruby\nmodule App\n  module Commands\n    class Config \u003c App::Command\n      def initialize(options)\n        @options = options\n      end\n\n      def execute\n        # Command logic goes here ...\n      end\n    end\n  end\nend\n```\n\nNotice that `Config` inherits from `App::Cmd` class which you have full access to. This class is meant to provide all the convenience methods to lay foundation for any command development. It will lazy load many [tty components](#3-components) inside helper methods which you have access to by opening up the `lib/app/command.rb` file.\n\nFor example in the `lib/app/command.rb` file, you have access to `prompt` helper for gathering user input:\n\n```ruby\n# The interactive prompt\n#\n# @see http://www.rubydoc.info/gems/tty-prompt\n#\n# @api public\ndef prompt(**options)\n  require 'tty-prompt'\n  TTY::Prompt.new(options)\nend\n```\n\nor a `command` helper for running external commands:\n\n```ruby\n# The external commands runner\n#\n# @see http://www.rubydoc.info/gems/tty-command\n#\n# @api public\ndef command(**options)\n  require 'tty-command'\n  TTY::Command.new(options)\nend\n```\n\nYou have full control of the file, so you can use only the [tty components](#3-components) that you require. Please bear in mind that all the components are added by default in your `app.gemspec` which you can change to suite your needs and pick only `tty` components that fit your case.\n\n### 2.4 Arguments\n\nA command may accept a variable number of arguments.\n\nFor example, if we wish to have a `config` command that accepts a location of configuration file, then we can run `teletype add` command passing `--args` flag:\n\n```bash\n$ teletype add config --args file\n```\n\nwhich will include the required `file` as an argument to the `config` method:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    desc 'config FILE', 'Set and get configuration options'\n    def config(file)\n      ...\n    end\n  end\nend\n```\n\nSimilarly, if we want to generate command with two required arguments, we run `teletype add` command with `--args` flag that can accept variable names delimited by space character:\n\n```bash\n$ teletype add set --args name value\n```\n\nwill generate the following:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    desc 'set NAME VALUE', 'Set configuration option'\n    def set(name, value)\n      ...\n    end\n  end\nend\n```\n\nIf we want to have a command that has an optional argument, for example, the `file` argument is an optional argument in the `config` command, then you need to enclose `--args` argument in parentheses:\n\n```bash\n$ teletype add config --args 'file = nil'\n```\n\nIn well behaved command line application, any optional argument in a command will be enclosed in square brackets:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    desc 'config [FILE]', 'Set and get configuration options'\n    def config(file = nil)\n      ...\n    end\n  end\nend\n```\n\nIf you intend for your command to accept any number of arguments, you need to prefix such argument with an asterisk. For example, if we wish to accept many configuration names:\n\n```bash\n$ teletype add get --args *names\n```\n\nwhich will append `...` to the argument description:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    desc 'get NAMES...', 'Get configuration options'\n    def get(*names)\n      ...\n    end\n  end\nend\n```\n\nYou can mix and match all the above styles of arguments definitions:\n\n```bash\n$ teletype add config --args file *names\n```\n\n### 2.5 Description\n\nUse the `desc` method call to describe your command when displayed in terminal. There are two arguments to this method. First, specifies the command name and the actual positional arguments it will accept. The second argument is an actual text description of what the command does.\n\nFor example, given the command `config` generated in [add command](#22-add-command) section, we can add description like so:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    desc 'config [FILE]', 'Set and get configuration options'\n    def config(file = nil)\n      ...\n    end\n  end\nend\n```\n\nRunning `app` executable will include the new description:\n\n```\nCommands:\n  app config [FILE]  # Set and get configuration options\n```\n\nTo provide long form description of your command use `long_desc` method.\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    desc 'config [FILE]', 'Set and get configuration options'\n    long_desc \u003c\u003c-DESC\n      You can query/set/replace/unset options with this command.\n\n      The name is an optional key separated by a dot, and the value will be escaped.\n\n      This command will fail with non-zero status upon error.\n    DESC\n    def config(file = nil)\n      ...\n    end\n  end\nend\n```\n\nRunning `app config --help` will produce the following output:\n\n```\nUsage:\n  app config\n\nYou can query/set/replace/unset options with this command.\n\nThe name is an optional key separated by a dot, and the value will be escaped.\n\nThis command will fail with non-zero status upon error.\n```\n\n### 2.6 Options and Flags\n\nFlags and options allow to customize how particular command is invoked and provide additional configuration.\n\nTo specify individual flag or option use `method_option` before the command method. All the flags and options can be accessed inside method body via the `options` hash.\n\nAvailable metadata for an option are:\n\n* `:aliases` - A list of aliases for this option.\n* `:banner` — A description of the value if the option accepts one.\n* `:default` - The default value of this option if it is not provided.\n* `:lazy_default` — A default that is only passed if the cli option is passed without a value.\n* `:desc` - The short description of the option, printed out in the usage description.\n* `:required` — Indicates that an option is required.\n* `:type` - `:string`, `:hash`, `:array`, `:numeric`, `:boolean`\n* `:enum` — A list of allowed values for this option.\n\nThe values for `:type` option are:\n\n* `:boolean` is parsed as `--option`\n* `:string` is parsed as `--option=VALUE` or `--option VALUE`\n* `:numeric` is parsed as `--option=N` or `--option N`\n* `:array` is parsed as `--option=one two three` or `--option one two three`\n* `:hash` is parsed as `--option=name:string age:integer`\n\nFor example, you wish to add an option that allows you to add a new line to a configuration file for a given key with a value thus being able to run `app config --add name value`. To do this, you would need to specify `:array` type for accepting more than one value and `:banner` to provide meaningful description of values:\n\n```ruby\nmethod_option :add, type: :array, banner: \"name value\", desc: \"Adds a new line the config file. \"\n```\n\nThe above option would be included in the `config` method like so:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    desc 'config [\u003cfile\u003e]', 'Set and get configuration options'\n    method_option :add, type: :array, banner: \"name value\",\n                        desc: \"Adds a new line the config file. \"\n    def config(*)\n      ...\n    end\n  end\nend\n```\n\nRunning `app help config` will output new option:\n\n```\nUsage:\n  app config [\u003cfile\u003e]\n\n  Options:\n    [--add=name value]  # Adds a new line the config file.\n```\n\nYou can also specify an option as a flag without an associated value. Let us assume you want to be able to open a configuration file in your system editor when running `app config --edit` or `app config -e`. This can be achieved by adding the following option:\n\n```ruby\nmethod_option :edit, type: :boolean, aliases: ['-e'],\n                     desc: \"Opens an editor to modify the specified config file.\"\n```\n\nAnd adding it to the `config` method:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    desc 'config [\u003cfile\u003e]', 'Set and get configuration options'\n    method_option :edit, type: :boolean, aliases: ['-e'],\n                         desc: \"Opens an editor to modify the specified config file.\"\n    def config(*)\n      ...\n    end\n  end\nend\n```\n\nNext, running `app help config` will produce:\n\n```\nUsage:\n  app config [\u003cfile\u003e]\n\nOptions:\n      [--add=name value]     # Adds a new line the config file.\n  -e, [--edit], [--no-edit]  # Opens an editor to modify the specified config file.\n```\n\nYou can use `method_options` as a shorthand for specifying multiple options at once.\n\n```ruby\nmethod_options %w(list -l) =\u003e :boolean, :system =\u003e :boolean, :local =\u003e :boolean\n```\n\nOnce all the command options and flags have been setup, you can access them via `options` hash in command file `lib/app/commands/config.rb`:\n\n```ruby\nmodule App\n  module Commands\n    class Config \u003c App::Command\n      def initialize(options)\n        @options = options\n      end\n\n      def execute\n        if options[:edit]\n          editor.open('path/to/config/file')\n        end\n      end\n    end\n  end\nend\n```\n\n### 2.7 Global Flags\n\nYou can specify an option or a flag that is applicable to all commands and subcommands within a given class by using the `class_option` method. This method takes exactly the same parameters as `method_option` for an individual command. The `options` hash in a given command will always include a global level flag information.\n\nFor example, if you want a global flag `debug` that is visible to all commands in your tool then you need to add it to your `CLI` class like so:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    class_option :debug, type: :boolean, default: false, desc: 'Run in debug mode'\n\n    ...\n  end\nend\n```\n\n### 2.8. Working with Subcommands\n\nIf your tool grows in complexity you may want to add more refined behaviour for each individual command, a subcommand is a great choice to accomplish this. For example, `git` utility and its `git remote` command have various subcommands `add`, `rename`, `remove`, `set-url`, `prune` and so on that themselves accept many options and arguments.\n\nThe `teletype` executable allows you to easily create new subcommands by issuing the same `add` command that is also used for generating commands. The only difference is that you need to provide a command name together with a subcommand name. For example, let's say we want the `config` with a `set` subcommand with a description and two positional arguments `name` and `value`:\n\n```bash\n$ teletype add config set --desc 'Set configuration option' --args name value\n```\n\nThis will add `set.rb` command to the `commands/config` folder:\n\n```\n▾ app/\n├── ▾ commands/\n│   ├── ▾ config/\n│   │   └── set.rb\n│   └── config.rb\n├── ▾ templates/\n│   └── ▾ config/\n│       └── ▸ set/\n├── cli.rb\n├── command.rb\n└── version.rb\n```\n\nThe `lib/app/cli.rb` will contain code that registers config namespace with our `CLI` root application:\n\n```ruby\nmodule App\n  class CLI \u003c Thor\n    require_relative 'commands/config'\n    register App::Commands::Config, 'config', 'config [SUBCOMMAND]', 'Set configuration option'\n  end\nend\n```\n\nThe `lib/app/commands/config.rb` will contain code that handles dispatching subcommands to the `Config` instance:\n\n```ruby\n# frozen_string_literal: true\n\nrequire 'thor'\n\nmodule App\n  module Commands\n    class Config \u003c Thor\n\n      namespace :config\n\n      desc 'set NAME VALUE', 'Set configuration option'\n      def set(name, value)\n        if options[:help]\n          invoke :help, ['set']\n        else\n          require_relative 'config/set'\n          App::Commands::Config::Set.new(name, value, options).execute\n        end\n      end\n    end\n  end\nend\n```\n\nAnd finally, the `lib/app/commands/config/set.rb` will contain the actual `set` command implementation:\n\n```ruby\n# frozen_string_literal: true\n\nrequire_relative '../../command'\n\nmodule App\n  module Commands\n    class Config\n      class Set \u003c App::Command\n        def initialize(name, value, options)\n          @name = name\n          @value = value\n          @options = options\n        end\n\n        def execute\n          # Command logic goes here ...\n        end\n      end\n    end\n  end\nend\n```\n\nYou can now run your command in terminal:\n\n```ruby\nbundle exec app config set debug true\n```\n\n**Note** that it is not possible to add subcommands to an existing command. Attempting to do so will currently cause `teletype` to crash. The reason why it is not possible to add subcommands to existing commands is that it is impossible for `tty` to distinguish between normal arguments to a command, and subcommands for that command. However, you may very well add multiple subcommands one after another.\n\n## 3. Components\n\nThe **TTY** allows you to mix \u0026 match any components you need to get your job done. The command line applications generated with `teletype` executable references all of the below components.\n\n|  Component   | Description | API docs |\n| ------------ | ----------- | -------- |\n| [pastel](https://github.com/piotrmurach/pastel) | Terminal strings styling with intuitive and clean API. | [docs](http://www.rubydoc.info/gems/pastel) |\n| [tty-box](https://github.com/piotrmurach/tty-box) | Draw various frames and boxes in your terminal. | [docs](http://www.rubydoc.info/gems/tty-box) |\n| [tty-color](https://github.com/piotrmurach/tty-color) | Terminal color capabilities detection. | [docs](http://www.rubydoc.info/gems/tty-color) |\n| [tty-command](https://github.com/piotrmurach/tty-command) | Execute shell commands with pretty logging and capture stdout, stderr and exit status. | [docs](http://www.rubydoc.info/gems/tty-command) |\n| [tty-config](https://github.com/piotrmurach/tty-config) | Define, read and write any Ruby app configurations with a penchant for terminal clients. | [docs](http://www.rubydoc.info/gems/tty-config) |\n| [tty-cursor](https://github.com/piotrmurach/tty-cursor) | Move terminal cursor around. | [docs](http://www.rubydoc.info/gems/tty-cursor) |\n| [tty-editor](https://github.com/piotrmurach/tty-editor) | Open a file or text in the user preferred editor. | [docs](http://www.rubydoc.info/gems/tty-editor) |\n| [tty-file](https://github.com/piotrmurach/tty-file) | File manipulation utility methods. | [docs](http://www.rubydoc.info/gems/tty-file) |\n| [tty-font](https://github.com/piotrmurach/tty-font) | Write text in large stylized characters using a variety of terminal fonts. | [docs](http://www.rubydoc.info/gems/tty-font) |\n| [tty-link](https://github.com/piotrmurach/tty-link) | Hyperlinks in your terminal. | [docs](http://www.rubydoc.info/gems/tty-link) |\n| [tty-logger](https://github.com/piotrmurach/tty-logger) | A readable and structured logging for the terminal. | [docs](http://www.rubydoc.info/gems/tty-logger) |\n| [tty-markdown](https://github.com/piotrmurach/tty-markdown) | Convert a markdown document or text into a terminal friendly output. | [docs](http://www.rubydoc.info/gems/tty-markdown) |\n| [tty-option](https://github.com/piotrmurach/tty-option) | Parser for command line arguments, keywords and options. | [docs](http://www.rubydoc.info/gems/tty-option) |\n| [tty-pager](https://github.com/piotrmurach/tty-pager) | Terminal output paging in a cross-platform way. | [docs](http://www.rubydoc.info/gems/tty-pager) |\n| [tty-pie](https://github.com/piotrmurach/tty-pie_chart) | Draw pie charts in your terminal window. | [docs](http://www.rubydoc.info/gems/tty-pie_chart) |\n| [tty-platform](https://github.com/piotrmurach/tty-platform) | Detecting different operating systems. | [docs](http://www.rubydoc.info/gems/tty-platform) |\n| [tty-progressbar](https://github.com/piotrmurach/tty-progressbar) | A flexible progress bars drawing in terminal emulators. | [docs](http://www.rubydoc.info/gems/tty-progressbar) |\n| [tty-prompt](https://github.com/piotrmurach/tty-prompt) | A beautiful and powerful interactive command line prompt. | [docs](http://www.rubydoc.info/gems/tty-prompt) |\n| [tty-reader](https://github.com/piotrmurach/tty-reader) | A set of methods for processing keyboard input in character, line and multiline modes. | [docs](http://www.rubydoc.info/gems/tty-reader) |\n| [tty-screen](https://github.com/piotrmurach/tty-screen) | Terminal screen properties detection. | [docs](http://www.rubydoc.info/gems/tty-screen)\n| [tty-spinner](https://github.com/piotrmurach/tty-spinner) | A terminal spinner for tasks with non-deterministic time.| [docs](http://www.rubydoc.info/gems/tty-spinner) |\n| [tty-table](https://github.com/piotrmurach/tty-table) | A flexible and intuitive table output generator. | [docs](http://www.rubydoc.info/gems/tty-table) |\n| [tty-tree](https://github.com/piotrmurach/tty-tree) | Print directory or structured data in a tree like format. | [docs](http://www.rubydoc.info/gems/tty-tree) |\n| [tty-which](https://github.com/piotrmurach/tty-which) | Platform independent implementation of Unix which command. | [docs](http://www.rubydoc.info/gems/tty-which) |\n\n## 4. Contributing\n\nYou can contribute by posting `feature requests`, evaluating the APIs or simply by hacking on TTY components:\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\nThis project uses [EditorConfig](https://editorconfig.org/) to maintain consistent tabbing and file formats. Consider [installing the plugin for your editor](https://editorconfig.org/#download) to help maintain proper code formatting.\n\n## Copyright\n\nCopyright (c) 2012 Piotr Murach. See LICENSE.txt for further details.\n","funding_links":["https://github.com/sponsors/piotrmurach"],"categories":["CLI Builder","Ruby","Happy Exploring 🤘","Additional Languages","cli","Awesome Ruby CLIs","[Ruby](https://www.ruby-lang.org/)"],"sub_categories":["Ruby 💎","Generating","Useful awesome list for Go cli"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrmurach%2Ftty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiotrmurach%2Ftty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrmurach%2Ftty/lists"}