{"id":13819862,"url":"https://github.com/refIekt/lit","last_synced_at":"2025-05-16T07:32:23.424Z","repository":{"id":144028127,"uuid":"334320101","full_name":"refIekt/lit","owner":"refIekt","description":"Shine a light on terminal commands. 🔥","archived":false,"fork":false,"pushed_at":"2021-03-05T04:41:56.000Z","size":4101,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-19T19:43:41.593Z","etag":null,"topics":["cli","filter-logs","lit","pry"],"latest_commit_sha":null,"homepage":"https://reflekt.dev/lit","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/refIekt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","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":"2021-01-30T03:35:52.000Z","updated_at":"2023-08-22T01:05:34.000Z","dependencies_parsed_at":"2024-05-28T18:21:23.066Z","dependency_job_id":"e6a54c9a-6771-40d7-a67d-810005e8bd79","html_url":"https://github.com/refIekt/lit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refIekt%2Flit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refIekt%2Flit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refIekt%2Flit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refIekt%2Flit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/refIekt","download_url":"https://codeload.github.com/refIekt/lit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254488406,"owners_count":22079424,"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","filter-logs","lit","pry"],"created_at":"2024-08-04T08:00:54.144Z","updated_at":"2025-05-16T07:32:21.504Z","avatar_url":"https://github.com/refIekt.png","language":"Ruby","funding_links":[],"categories":["Happy Exploring 🤘","Ruby"],"sub_categories":[],"readme":"# Lit CLI\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.mozilla.org/MPL/2.0/\" alt=\"MPLv2 License\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-MPLv2-blue.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://rubygems.org/gems/lit-cli\"\u003e\n    \u003cimg src=\"https://badge.fury.io/rb/lit-cli.svg\" alt=\"Gem Version\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/github/languages/code-size/refIekt/lit\" alt=\"GitHub code size in bytes\"\u003e\n  \u003cimg src=\"https://img.shields.io/gem/dt/lit-cli\"\u003e\n\u003c/p\u003e\n\n*Shine a light on terminal commands.* 🔥\n\nLit lets you create console logs that are only visible after prefixing a command with `lit`. You can use flags to filter the types of logs and step through your application at runtime, essentially turning your logs into breakpoints. You can press Enter to continue to the next step or press P to begin a [Pry](https://github.com/pry/pry) session. Lit was originally created to view the reflections generated by [Reflekt](https://reflekt.dev) via the command line, but can be used in a range of applications.\n\n## Usage\n\nSimply start any command with `lit`. For example a script like `ruby script.rb` becomes:\n```\nlit ruby script.rb\n```\n\nThen run the application and watch the terminal window for Lit messages:\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"/assets/images/lit.png\" width=\"850\"/\u003e\n\u003c/p\u003e\n\n### Flags\n\nLit accepts flags to modify behaviour. They are prefixed with an `@` and appended after the `lit` command:\n```\nlit @\u003cflag-name\u003e ruby \u003cscript-name\u003e.rb\n```\n\nFlags start with an `@` instead of a `--` so that they aren't confused with flags for the original command that Lit is firing off.\n\n#### @step\n\n\u003cimg src=\"/assets/gifs/step.gif\" width=\"750\"/\u003e\n\nStep through the code. The terminal will stop at each `lit()` message, then prompt you to press *Enter* to continue to the next message or press *P* to enter a Pry session.\n```\nlit @step ruby script.rb\n```\n\nWhen in a Pry session, enter `x` to exit Pry or `!!!` to exit the program (use `x;` to access a variable called `x`).\n\n**Note:** Only files required via `require_relative` are currently supported for Pry session.  \n**Note:** Pry is not available to `lit()` messages in the *first* file to `require 'lit_cli'`, so require Lit in your application's entry point / main file if you need this feature.\n\n#### @status\n\nFilter logs by message status:\n```\nlit @status=error ruby script.rb\n```\n\nMultiple statuses are comma separated:\n```\nlit @status=fail,error ruby script.rb\n```\n\n#### @type\n\nFilter logs by message type:\n```\nlit @type=cat,dog ruby script.rb\n```\n\nTypes are optional and represent the type of data, similar to a class.\n\n#### @delay\n\n\u003cimg src=\"/assets/gifs/delay.gif\" width=\"750\"/\u003e\n\nDelay the execution of a message to make fast outputting logs easier to read. The default delay is `0` seconds (no delay) but can be any positive `Integer` or `Float`, for example:\n```\nlit @delay=1 ruby script.rb\n```\n\n## Installation\n\nIn Gemfile add:\n```ruby\ngem 'lit-cli'\n```  \n\nIn terminal run:\n```\nbundle install\n```\n\nOr:\n```\ngem install lit-cli\n```\n\nIf an application is currently using Lit then the `lit` command will already be available in your terminal without any installation required.\n\n## API\n\nInstructions for integrating your application with Lit.\n\n### Usage\n\nRequire `lit_cli` at the top of your file:\n```ruby\nrequire 'lit_cli'\n```\n\nInclude `LitCLI` in your `module` or `class`:\n```ruby\nclass ExampleClass\n  include LitCLI\n```\n\nThen use the `lit()` instance method:\n```ruby\nlit \"message\"\n```\n\n### lit()\n\n```ruby\nlit(message, status = :info, type = nil, context = nil)\n```\n\n* String `message` - The message to show.\n* Symbol `status` (optional) - The status of the message such as `:info`, `:warn` or `:error`.\n* Symbol `type` (optional) - The type of data this message represents such as `:cat` or `:dog`.\n* String `context` (optional) - The current class name or instance ID, anything that gives context.\n\nAvailable statuses and types can be configured, see `lib/config.rb` and `demo/demo.rb` for more info.\n\n### Symbols\n\nSpecial characters convey extra meaning when embedded in the `message` string.\n\n#### method()\n\n```ruby\nlit \"message method()\"\n```\n\nPlacing `()` next to a word will style them as a method.\n\n#### #number\n\n```ruby\nlit \"message #1\"\n```\n\nPlacing a `#` next to a number will style them as a number.\n\n#### \u003eindent\n\n```ruby\nlit \"\u003e message\"\n```\n\nPlacing a `\u003e` at the start of a message will indent the log in the console. Multiple `\u003e\u003e\u003e` symbols can be used and for each one, two spaces of indentation will be added. Indentation is not preserved when using `@status` or `@type` filters.\n\n#### ^separator\n\n```ruby\nlit \"^ message\"\n```\n\nPlacing a `^` at the start of a message will add a line break above the log in the console. Multiple `^^^` symbols can be used and for each one, one line break will be added. Line breaks are not preserved when using `@status` or `@type` filters.\n\n### Code as comments\n\nYou can use the `lit()` method in place of comments to help document your code. This:\n```ruby\n# Create control for method.\ncontrol = Control.new(action, 0, @@reflekt.aggregator)\naction.control = control\n```\n\nBecomes this:\n```ruby\nlit \"Create control for #{method} method\"\ncontrol = Control.new(action, 0, @@reflekt.aggregator)\naction.control = control\n```\n\nNow you've commented your code and your comments double as logs.\n\n### Emoji support\n\nYou can even use the emoji `🔥()` instead of `lit()` to call the method... cause why not? Climate change is real and we're all going to die anyway. So the final code could be:\n\n```ruby\n🔥 \"Create control for #{method} method\"\ncontrol = Control.new(action, 0, @@reflekt.aggregator)\naction.control = control\n```\n\nThe lit emoji acts as a nice sectional heading too. These are all just ideas and it's up to you to decide how to write code and save the future of humanity.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FrefIekt%2Flit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FrefIekt%2Flit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FrefIekt%2Flit/lists"}