Skip to content

Commit

Permalink
update some tool command
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Aug 12, 2020
1 parent 59ee29e commit 126fd9e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/Console/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected function execute($input, $output)
// Sys::execute($commands, false);
$command = $this->replaceScriptVars($name, $commands, $runArgs);
CmdRunner::new($command)->do(true);
$output->info('DONE: ' . $command);
return;
}

Expand All @@ -114,6 +115,7 @@ protected function execute($input, $output)

$command = $this->replaceScriptVars($name, $command, $runArgs);
CmdRunner::new($command)->do(true);
$output->info('DONE: ' . $command);
}
return;
}
Expand All @@ -138,7 +140,9 @@ private function replaceScriptVars(string $name, string $cmdString, array $scrip
throw new PromptException("missing arguments for run script '{$name}'");
}

$pairs = [];
$pairs = [
'$@' => implode(' ', $scriptArgs),
];

// like bash script, first var is '$1'
foreach ($scriptArgs as $i => $arg) {
Expand Down
24 changes: 24 additions & 0 deletions app/Console/Controller/GitLabController.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,28 @@ public function linkInfoCommand(Input $input, Output $output): void
$output->title('link information', ['indent' => 0]);
$output->json($info);
}

/**
* sync codes from remote main repo
*
* @options
* -b, --branch The sync code branch name, default is current branch(<info>{curBranchName}</info>)
* -r, --remote The main remote name, default: {mainRemote}
* --push Push to origin remote after update
*
* @param Input $input
* @param Output $output
*
* @example
* {binWithCmd} Sync code from the main repo remote {curBranchName} branch
* {binWithCmd} -b master Sync code from the main repo remote master branch
*
*/
public function syncCommand(Input $input, Output $output): void
{
$binName = $input->getBinName();
$output->info("TIPS:\n $binName gl:pr -o -t BRANCH");

Console::app()->dispatch('gf:sync');
}
}
37 changes: 34 additions & 3 deletions app/Console/Controller/UtilController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@
*/
class UtilController extends Controller
{
public const JB_NAME = 'JetBrains';
public const JB_TBOX = 'Toolbox';
public const JB_ALL = [
'IntelliJIdea',
'CLion',
'PhpStorm',
'GoLand',
'PyCharm',
'WebStorm',
'Rider',
'DataGrip',
'RubyMine',
'AppCode',
];

public const JB_NORMAL = [
'IntelliJIdea',
'CLion',
'PhpStorm',
'GoLand',
];

protected static $name = 'util';

protected static $description = 'Some useful development tool commands';
Expand Down Expand Up @@ -58,13 +80,22 @@ public function timeConvCommand(Input $input, Output $output): void
foreach ($args as $time) {
$data[] = [
'timestamp' => $time,
'datetime' => date('Y-m-d H:i:s', (int)$time),
'datetime' => date('Y-m-d H:i:s', (int)$time),
];
}

$output->colored('- Current Time: ' . date('Y-m-d H:i:s'));
$output->table($data, 'Time to date', [
// opts
$output->table($data, 'Time to date', [// opts
]);
}

/**
* find IDEA in the machine
*/
public function findJetBrainsCommand(): void
{
// ~/Library/Preferences/PhpStorm2019.3/
// ~/Library/Application\ Support/JetBrains/
// ~/Library/Application\ Support/JetBrains/Toolbox/apps/
}
}
2 changes: 1 addition & 1 deletion app/Helper/AppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function openBrowser(string $pageUrl): void
$cmd = 'x-www-browser';
}

Show::info("Will open the page on browser: $pageUrl");
Show::info("Will open the page on browser:\n $pageUrl");
Sys::execute($cmd . " \"{$pageUrl}\"");
}
}

0 comments on commit 126fd9e

Please sign in to comment.