Repository navigation
Better CLI - #2372
Better CLI#2372
Conversation
If the `url` passed to the openDesktop function contained shell metacharacters, they would not get escaped, leading to arbitrary code execution.
| import * as QueryString from 'querystring' | ||
| import { URL } from 'url' | ||
|
|
||
| import * as yargs from 'yargs' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
I forgot to mention that this PR depends on this PR, which should be published to npm in the near future. |
|
I'd like to look at whether we can make webpack happy with |
|
As this currently stands it adds a significant amount JS to the
|
|
Do you know if it would be possible to dynamically generate the import * as yargs from 'yargs'
import * as clone from './commands/clone'
import * as open from './commands/open'
// import * as ${fileName} from './commands/${fileName}'
yargs
.command(clone)
.command(open)
// .command(${fileName})
.help().argv |
|
Updated and shrinkified: |
|
⏩ |
joshaber
left a comment
There was a problem hiding this comment.
This definitely looks much nicer/friendlier than it did before 😍
⛱
| import { ICommandModule, mriArgv } from '../load-commands' | ||
|
|
||
| interface ICloneArgs extends mriArgv { | ||
| pr?: number |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| args: [ | ||
| { | ||
| name: 'path', | ||
| description: 'The path to the repository to open. Defaults to `.`', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| const command = __DARWIN__ ? 'open' : 'start' | ||
| ChildProcess.exec(`${command} ${url}`, { env }) | ||
| /// <reference path="../../typings/mri.d.ts"/> |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| args = [name] | ||
| runCommand('help') | ||
| } | ||
| })(commandArg) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| "@types/ua-parser-js": "^0.7.30", | ||
| "@types/uuid": "^2.0.29", | ||
| "@types/winston": "^2.2.0", | ||
| "@types/yargs": "^8.0.2", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| cloneUrl = `https://github.com/${cloneUrl}` | ||
| } | ||
| if (pr) { | ||
| branch = 'pr/' + pr |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| pr: { | ||
| type: 'number', | ||
| aliases: ['p'], | ||
| description: 'The PR branch to switch to after cloning', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| type: 'string', | ||
| }, | ||
| { | ||
| name: 'path', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| export { mriArgv } | ||
|
|
||
| export interface IOption { | ||
| type: TypeName |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| unknownOptionHandler?: (flag: string) => void | ||
| } | ||
|
|
||
| const loadModule: (name: string) => ICommandModule = name => |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Ugh, found this which I thought was previously working: Also |
Upstream changes have been merged in, gotta start over
|
@shiftkey That error was because I forgot to prepend the protocol to the URL in |
|
From #2775:
Note: |
|
Why? It seems like a good default. |
Two things I think of which would annoy me:
I'd rather leave the defaults as "launch the app to whatever you had previously", the two extra characters are a minor inconvenience and eliminate opportunities to confuse users. |
|
Ah, that's a good point. I sometimes will be doing random stuff in my shell and want to launch GitHub real quick. If I'm in |
|
I've opened #2832 to track the first item as that's a bug which also affects drag-and-dropping subfolders of repositories into the app, and can be fixed separate to this. I'm going to leave the second item aside unless others have strong feelings on this and can convince me otherwise. |
|
Not sure if this is the issue to ask on, but on #2775 it was mentioned that running just Is that still a possibility? If so, is there any documentation or adjustments I could help with? Thanks! |
|
@blakek I'm not a fan of making |
|
Alright, I think this is ready to go. As I've been involved with this I'm going to need someone else to 👍 it and hit the green button. Happy to answer any other questions that the reviewer might have in the meantime. |
|
🌈 |
|
🎉 🎉 🎉 |

✨ ✨ ✨
Run it locally (
npm -s run cli -- [...args]) to get the full experience.