-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5cd23f
commit 96a0e8a
Showing
5 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.idea | ||
.phpunit.result.cache | ||
.composer/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "minicli/command-demo", | ||
"type": "library", | ||
"description": "A demo shareable command for Minicli", | ||
"license": "MIT", | ||
"homepage": "https://github.com/minicli/command-demo", | ||
"keywords": ["cli","command-line", "template"], | ||
"autoload": { | ||
"psr-4": { | ||
"Minicli\\": "src/" | ||
} | ||
}, | ||
"require": { | ||
"minicli/minicli": "^3.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
if (php_sapi_name() !== 'cli') { | ||
exit; | ||
} | ||
|
||
require __DIR__ . '/vendor/autoload.php'; | ||
|
||
use Minicli\App; | ||
use Minicli\Exception\CommandNotFoundException; | ||
|
||
$app = new App([ | ||
'app_path' => [ | ||
__DIR__ . '/src' | ||
], | ||
'debug' => true | ||
]); | ||
|
||
$app->setSignature('./minicli demo param1=value1 param2=value2'); | ||
|
||
try { | ||
$app->runCommand($argv); | ||
} catch (CommandNotFoundException $notFoundException) { | ||
$app->getPrinter()->error("Command Not Found."); | ||
return 1; | ||
} catch (Exception $exception) { | ||
if ($app->config->debug) { | ||
$app->getPrinter()->error("An error occurred:"); | ||
$app->getPrinter()->error($exception->getMessage()); | ||
} | ||
return 1; | ||
} | ||
|
||
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Minicli\Demo; | ||
|
||
use Minicli\Command\CommandController; | ||
|
||
class DefaultController extends CommandController | ||
{ | ||
public function handle(): void | ||
{ | ||
$name = $this->hasParam('user') ? $this->getParam('user') : 'World'; | ||
$this->getPrinter()->display(sprintf("Hello, %s!", $name)); | ||
|
||
print_r($this->getParams()); | ||
} | ||
} |