Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add CLI Support #57

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
},
"args" : ["."],
"outputCapture": "std"
}
]
}
50 changes: 50 additions & 0 deletions cli/cli-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env node
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')

yargs(hideBin(process.argv))
.command('list [region]', 'List all currently known IP ranges (and cluster ids) on a given Cluster ID', (yargs) => { // todo re-work description its gross
return yargs
.positional('region', {
describe: 'specific geographic region/cluster for Matchmaking Servers',
default: 'all'
})
}, (argv) => {
if (argv.verbose) console.info(`List servers on :${argv.region}`)

console.log('Listed the Servers');
})
.command('reset', 'Remove all CSGO Matchmaking Server Firewall rules', (argv) => {

console.log('🔥🔥🔥 All firewall rules removed successfully! 🔥🔥🔥')
})
.command('set region [regionid]', 'Sets a given specified region as the default for Matchmaking', (yargs) => {
return yargs
.positional('regionid', {
describe: 'specific geographic region for Matchmaking Servers',
default: 'oc'
})
}, (argv) => {

console.log(`Set region: ${argv.regionid} for CSGO Matchmaking. Firewall has been changed.`)
})
.command('ping region [regionid] [amount]', 'Pings a given specified region/cluster and displays output.', (yargs) => {
return yargs
.positional('regionid', {
describe: 'specific geographic region for Matchmaking Servers',
default: 'oc'
})
.positional('amount', {
describe: 'The amount of times to ping a particular region\'s servers',
default: '5'
})
}, (argv) => {

console.log(`Pinging region: ${argv.regionid}, ${argv.amount} times for CSGO Matchmaking. ⚠ Firewall has NOT been changed. ⚠`)
})
.option('verbose', {
alias: 'v',
type: 'boolean',
description: 'Run with verbose logging'
})
.argv
38 changes: 38 additions & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "csgo-mm-picker-cli",
"version": "0.0.1",
"description": "A command-line interface option for the CSGO Matchmaking Server Picker",
"main": "cli-main.js",
"scripts": {
"test": "echo \"No tests currently available.\" && exit 1",
"csgo-server-picker": "node cli-main.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Jyben/csgo-mm-server-picker.git"
},
"devDependencies": {
"electron": "^9.4.0",
"electron-builder": "^22.9.1"
},
"dependencies": {
"axios": "^0.21.1",
"electron-log": "^3.0.6",
"electron-updater": "^4.3.1",
"glob": "^7.1.4",
"simple-node-logger": "^18.12.24",
"sudo-prompt": "^8.2.5",
"yargs": "^16.2.0"
},
"keywords": [
"csgo",
"mm",
"cli"
],
"author": "Adam Grande",
"license": "MIT",
"bugs": {
"url": "https://github.com/Jyben/csgo-mm-server-picker/issues"
},
"homepage": "https://github.com/Jyben/csgo-mm-server-picker#readme"
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.