{"id":20676011,"url":"https://github.com/sammwyy/captainjs","last_synced_at":"2025-04-19T20:54:54.068Z","repository":{"id":57194214,"uuid":"283705703","full_name":"sammwyy/captainjs","owner":"sammwyy","description":"A toolkit for NodeJS which contains Debugger and Console Utilities.","archived":false,"fork":false,"pushed_at":"2020-08-27T22:38:11.000Z","size":52,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T13:21:56.353Z","etag":null,"topics":["color","commands","console","debug","debugger","debugging","debugging-tool","library","logger","nodejs","nodejs-modules"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/sammwyy.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":"2020-07-30T07:51:22.000Z","updated_at":"2024-12-11T22:00:37.000Z","dependencies_parsed_at":"2022-09-01T00:51:02.053Z","dependency_job_id":null,"html_url":"https://github.com/sammwyy/captainjs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammwyy%2Fcaptainjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammwyy%2Fcaptainjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammwyy%2Fcaptainjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammwyy%2Fcaptainjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sammwyy","download_url":"https://codeload.github.com/sammwyy/captainjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248726248,"owners_count":21151863,"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":["color","commands","console","debug","debugger","debugging","debugging-tool","library","logger","nodejs","nodejs-modules"],"created_at":"2024-11-16T21:11:26.985Z","updated_at":"2025-04-19T20:54:53.996Z","avatar_url":"https://github.com/sammwyy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg align=\"left\" src=\"https://raw.githubusercontent.com/sammwyy/captainjs/master/docs/assets/captain.png\" width=\"10%\"\u003e\n\n### Captain.js\nA toolkit for NodeJS which contains Debugger and Console Utilities.  \n\u003cp align=\"center\"\u003e \u003ca href=\"#debugger\"\u003eDebugger\u003c/a\u003e | \u003ca href=\"#console\"\u003eConsole\u003c/a\u003e | \u003ca href=\"#colors\"\u003eColors\u003c/a\u003e | \u003ca href=\"#commands\"\u003eCommands\u003c/a\u003e\n\n#### What is Captain.js?\nCaptain.js is a toolkit that provides console utilities such as debugging, logging, and commands.  \n\n### Console\n**Format console**  \nadd formats to the console that apply automatic colors, prefixes and other utilities.\n```javascript\nconst Captain = require('captainjs');\nconsole = new Captain.Console();\n\nconsole.log(\"Hello\");\nconsole.error(\"This is an error\");\nconsole.warn(\"Warning! you are awesome.\");\n```\n\n\u003e Output:  \n[23:57:44] [Log] Hello  \n[23:57:44] [Error] This is an error  \n[23:57:44] [Warn] Warning! you are awesome.  \n\n\n\n**Custom Console configuration**  \nAll parameters are optional.\n```javascript\nconsole = new Captain.Console({\n    \"use_colors\": true,\n    \"debug\": false,\n    \"format\": \"§8[§d%time%§8] [%prefix%§8] §7%message%\",\n    \"log_prefix\": \"§aLog\",\n    \"warn_prefix\": \"§eWarn\",\n    \"error_prefix\": \"§cError\",\n    \"info_prefix\": \"§bInfo\",\n    \"debug_prefix\": \"§bDebug\"\n});\n```\n\n\n\n\n### Colors\n**Colors in console**  \nJust do a console.log (); containing a string with color scapes.\n```javascript\nconst Captain = require('captainjs');\nconsole = new Captain.Console();\n\nconsole.log(\"§dHello in Purple §aAnd goodbye in green\");\n```\n\nColors:  \n§0 = Black  \n§1 = Dark Blue  \n§2 = Dark Green  \n§3 = Dark Cyan  \n§4 = Dark Red  \n§5 = Dark Purple  \n§6 = Gold  \n§7 = Gray  \n§8 = Dark Gray  \n§9 = Blue  \n§a = Green  \n§b = Aqua  \n§c = Red  \n§d = Purple  \n§e = Yellow  \n§f = White  \n§r = Reset  \n\n\n\n**Colors in console using the Enumerator**  \nYou can concatenate a string to a color using the following enumerator.\n```javascript\nconst Color = require(\"captainjs\").Colors;\n\nconsole.log(Color.Red + \"Hello\");\n```\n\n\n\n\n### Debugger\n**Normal debugger**  \nIt shows in the console when the function is called, which in turn contains where it is called from and in which line of code.\n```javascript\nconst Captain = require('captainjs');\nconst Debug = new Captain.Debugger();\n\nDebug.call();\n```\n\n\u003e Output:  \nDebug called from Object.\u003canonymous\u003e(); || test.js:4:7\n  \n  \n\n**Debugger with message**  \nIt shows a message in the console when the function is called, which in turn contains where it is called from and in which line of code.\n```javascript\nconst Captain = require('captainjs');\nconst Debug = new Captain.Debugger();\n\nDebug.call(\"This works?\");\n```\n\n\u003e Output:  \nThis works? || test.js:4:7\n\n\n\n**Debugger with console object**\n```javascript\nconst Captain = require('captainjs');\nconsole = new Captain.Console();\n\nconsole.debug();\n```\n\u003e Output:  \n[23:57:44] [Debug] Debug called from Object.\u003canonymous\u003e(); || test.js:5:9\n\n\n\n\n### Commands\n**Register a command**  \nRegisters a function that will be executed when the specified command is written to the terminal.  \n```javascript\nconst Captain = require('captainjs');\nconst Commander = new Captain.Commander();\n\nCommander.registerCommand(\"hello\", (args) =\u003e {\n    console.log(\"Hello world\");\n});\n\nCommander.fetch();\n```\n\n\n\n**Change the command input prefix**  \nchange the text to be displayed when a command needs to be sent.  \n```javascript\nCommander.setPrefix(\"Type a command here: \");\n```\n\n\n\n**Handle unknown commands**  \nexecutes an action when trying to execute a non-existent command.  \n```javascript\nCommander.onUnknownCommand((cmd) =\u003e {\n    console.error(\"Invalid Command: \" + cmd);\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammwyy%2Fcaptainjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsammwyy%2Fcaptainjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammwyy%2Fcaptainjs/lists"}