{"id":18034630,"url":"https://github.com/austinkregel/forge-cli","last_synced_at":"2025-04-04T23:12:11.409Z","repository":{"id":24316121,"uuid":"101114763","full_name":"austinkregel/forge-cli","owner":"austinkregel","description":"A simple to use node cli framework","archived":false,"fork":false,"pushed_at":"2022-06-19T21:01:47.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T07:29:56.735Z","etag":null,"topics":["cli-framework","forge-cli","hacktober","hacktoberfest","javascript-framework","npm-package"],"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/austinkregel.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"austinkregel","ko_fi":"kregel","tidelift":"npm/forge-cli","custom":"https://beerpay.io/austinkregel/forge-cli"}},"created_at":"2017-08-22T22:59:41.000Z","updated_at":"2022-06-19T20:59:04.000Z","dependencies_parsed_at":"2022-08-29T22:21:32.075Z","dependency_job_id":null,"html_url":"https://github.com/austinkregel/forge-cli","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinkregel%2Fforge-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinkregel%2Fforge-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinkregel%2Fforge-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinkregel%2Fforge-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/austinkregel","download_url":"https://codeload.github.com/austinkregel/forge-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261605,"owners_count":20910108,"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-framework","forge-cli","hacktober","hacktoberfest","javascript-framework","npm-package"],"created_at":"2024-10-30T11:13:01.821Z","updated_at":"2025-04-04T23:12:11.381Z","avatar_url":"https://github.com/austinkregel.png","language":"JavaScript","readme":"# What is forge-cli?\nIt's the beginning of a simple cli framework heavily inspired by [Laravel Artisan](https://laravel.com/docs/master/artisan). Specifically the way they handle anonymous cli commands and registering new commands. I'm not saying the code base is based upon it. Just the way you interact with everything.\n\n## So how do I use it?\n```\nyarn add forge-cli\n```\nor\n```\nnode add --save forge-cli\n```\nthen somewhere in you script\n\n```js\nvar Application = require('forge-cli');\n// and register a command like so.\nApplication.register(__dirname, [\n    './relative/path/from/__dirname/to/file'\n])\n// and individual commands like so\nApplication.command('command {argument} --option', function() {\n    // your code here!\n})\n```\n\n\n## docs\n\n#### Registering new commands\nEventually this will be done more simply; however, at this moment I have only added support though.\n\n\nIf we wanted to register the usage of the following command\n`node index.js your:command MyArgument --yourOption=no`\n\nthe code we would need to make it work is below.\n```javascript\nApplication.command('your:command {yourArgument} {--yourOption}', function() {\n    // Your code to execute when the command is called.\n    // this.option('yourOption') will either return the \n    // value it's set equal to (in the example it would be the word \"no\",\n    // true if it exists, or false if it doesn't exist.\n    \n    // this.argument('yourArgument') will return the text that's passed\n    // in it's place (in the example it would be the word \"MyArgument\") or null\n});\n```\n#### Real life example.\n\nIf you have a webhook that you want to post to you might do something like:\n\n```javascript\n'use strict';\nlet Application = require('forge-cli');\n    // I'm using axios to make an http request, you can use anything in this closure,\n    // I just like axios for http requests...\nlet axios = require('axios');\n\n// Register your command\nApplication.command('http:post {url} {--https}', function() {\n    let isSecure = this.option('https'),\n        urlToPostTo = this.argument('url');\n    // Use axios to post to the url\n    axios.post((isSecure? 'https://' : 'http://') + urlToPostTo, {})\n        .then(response =\u003e {\n            console.log(response.status)\n        })\n});\n\nlet args = Object.assign({}, {args: process.argv});\n\n// This \"starts\" the application\nApplication.start(args);\n```\nThen to use this command you can just type (in your console)\n\n`node index.js http:post example.com` or `node index.js http:post example.com --https`\nAnd the url's they'll hit are http://example.com and https://example.com respectively.\n\n### Helpers?\n\nYou have full access to the [inquirer](https://github.com/SBoudrias/Inquirer.js) library via `this.inquirer` in your command's closure.\n\n## Support on Beerpay\nHey dude! Help me out for a couple of :beers:!\n\n[![Beerpay](https://beerpay.io/austinkregel/forge-cli/badge.svg?style=beer-square)](https://beerpay.io/austinkregel/forge-cli)  [![Beerpay](https://beerpay.io/austinkregel/forge-cli/make-wish.svg?style=flat-square)](https://beerpay.io/austinkregel/forge-cli?focus=wish)","funding_links":["https://github.com/sponsors/austinkregel","https://ko-fi.com/kregel","https://tidelift.com/funding/github/npm/forge-cli","https://beerpay.io/austinkregel/forge-cli"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustinkregel%2Fforge-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faustinkregel%2Fforge-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustinkregel%2Fforge-cli/lists"}