Skip to content

Commit 1820af6

Browse files
committed
WIP: Add to run command
1 parent 26144e9 commit 1820af6

File tree

4 files changed

+61
-12
lines changed

4 files changed

+61
-12
lines changed

bin/Commands/JVM/RunCommand.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
namespace PHPJava\Console\Commands\JVM;
3+
4+
use Symfony\Component\Console\Command\Command;
5+
use Symfony\Component\Console\Input\InputArgument;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Input\InputOption;
8+
use Symfony\Component\Console\Output\OutputInterface;
9+
10+
class RunCommand extends Command
11+
{
12+
protected static $defaultName = 'jvm:run';
13+
14+
protected function configure()
15+
{
16+
$this
17+
->setDescription('Run JVM')
18+
->addOption(
19+
'options',
20+
'o',
21+
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
22+
'Set options'
23+
)
24+
->addOption(
25+
'mode',
26+
'm',
27+
InputOption::VALUE_OPTIONAL,
28+
'Set run mode [jar|class]. Default is class.'
29+
)
30+
->addOption(
31+
'entrypoint',
32+
'e',
33+
InputOption::VALUE_OPTIONAL,
34+
'Overwrite entrypoint'
35+
)
36+
->addArgument(
37+
'parameters',
38+
InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
39+
'Define parameters to pass for entrypoint.'
40+
);
41+
}
42+
43+
protected function execute(InputInterface $input, OutputInterface $output)
44+
{
45+
$options = $input->getOptions();
46+
}
47+
}

bin/PHPJava.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
2+
namespace PHPJava\Console;
23

4+
use PHPJava\Console\Commands\JVM\RunCommand;
35
use PHPJava\Core\JavaArchive;
46
use PHPJava\Core\PHPJava;
7+
use Symfony\Component\Console\Application;
58

69
require __DIR__ . '/../vendor/autoload.php';
710

8-
if (!isset($argv[1])) {
9-
echo "First parameter is needed.\n";
10-
return;
11-
}
12-
13-
$jar = new JavaArchive($argv[1]);
14-
$arguments = array_slice($argv, 2);
15-
$jar->execute(...(array_slice($argv, 2) ?: [[]]));
11+
$application = new Application();
12+
$runCommand = new RunCommand();
13+
$application->add($runCommand);
14+
$application->setDefaultCommand($runCommand->getName());
15+
$application->run();

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "JVM emulator by PHP",
44
"type": "library",
55
"license": "MIT",
6-
"version": "0.0.6.5-dev",
6+
"version": "0.0.6.6-dev",
77
"authors": [
88
{
99
"name": "memory"
@@ -18,11 +18,13 @@
1818
"php-java/java-io-package": "*",
1919
"php-java/java-net-package": "*",
2020
"php-java/java-nio-package": "*",
21-
"gabrielelana/byte-units": "dev-master"
21+
"gabrielelana/byte-units": "dev-master",
22+
"symfony/console": "^4.3@dev"
2223
},
2324
"autoload": {
2425
"psr-4": {
25-
"PHPJava\\": "src/"
26+
"PHPJava\\": "src/",
27+
"PHPJava\\Console\\": "bin/"
2628
}
2729
},
2830
"autoload-dev": {

src/Core/PHPJava.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ final class PHPJava
1212
/**
1313
* As same as composer version.
1414
*/
15-
const VERSION = 0x000065;
15+
const VERSION = 0x000066;
1616
}

0 commit comments

Comments
 (0)