Updates to command-line arguments #2013
Updates to command-line arguments #2013flightmansam wants to merge 3 commits intominbrowser:masterfrom
Conversation
Now calling min with the -t argument and a query will try and add the new tab into a specific task (or create one) Todos: - Refactor search and sort tasks and the move/switch to task to a more general location of the souce code as it is no longer just used for customBangs NB: this commit includes the electron API change to app.requestSingleInstanceLock(process.argv) in main which fixes a bug with chromium scrambling of second instance commandline args.
Added ability to pass in the task ID to the query Added a switch to task IPC
PalmerAL
left a comment
There was a problem hiding this comment.
Good idea!
I use the searchAndSortTasks and moveToTaskCommand from customBangs.js, so this should be separated out (probably to task.js)
I think the moveToTaskCommand call can be removed (explained in comments). Separating searchAndSortTasks does seem like a good idea, it could either go in a file in js/util or maybe a method on tasks?
| // check for -t task query | ||
| if (argv.includes('-t') && argv.indexOf('-t') > 0){ | ||
| // query for specific task to add search to | ||
| initTaskQuery = argv[argv.indexOf('-t') + 1] |
There was a problem hiding this comment.
I think we can assume that IPC messages will be received in the order they're sent, in which case we can just send a switchToTask IPC here, and then leave the code below as switchToTab without any task information. That should simplify this a fair amount.
| }) | ||
|
|
||
| app.on('second-instance', function (e, argv, workingDir) { | ||
| app.on('second-instance', function (e, argv, workingDir, additionalData) { |
There was a problem hiding this comment.
argv here should be the arguments of the second instance already - why do they need to be passed in with additionalData?
| // if there is no result, need to create a new task | ||
| let task | ||
|
|
||
| if (/^\d+$/.test(data.taskQuery)) { |
There was a problem hiding this comment.
Maybe this would be simpler / better as:
if (tasks.get(data.taskQuery)) {
task = tasks.get...
} else {
task = searchAndSortTasks...
}
if (!task) {
task = tasks.get(tasks.add(...
}
So task IDs would work, but any number that's not a task ID would be used for search or to create a new task.
| task.name = data.taskQuery | ||
| } | ||
|
|
||
| moveToTaskCommand(task.id) |
There was a problem hiding this comment.
IIUC, this is creating a tab in the current task, then using moveToTaskCommand to move it to the new task. This should just be a switchToTask call before the addTab call instead.
(However, if we send a switchToTask IPC from the main process, as I suggested in my other comment, this whole block of code should go away anyway).
|
Sorry I have done nothing more on this topic! Not a very high priority for me at the moment ahah. |
|
No worries! |
Discussed in #2008.
I would like to add a
-targument to request specific tasks from the command-line. This may be an opportunity to look at the code structure of how min handles command-line arguments to avoid confusion, inadvertent bugs, and easier extension later on. One opportunity could be to use a specific library like commander.js.This branch has some uglies at the moment due to my agile desire to just have the feature I want: