From 81dea747b25a183f60232ca53419db71a8f8f29c Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Tue, 1 Nov 2016 16:19:38 +0100 Subject: [PATCH] Doccomment can now override context command name --- examples/simple.php | 1 + lib/Context.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/simple.php b/examples/simple.php index 6e02f18..95b0749 100644 --- a/examples/simple.php +++ b/examples/simple.php @@ -17,6 +17,7 @@ class MyCommand extends Command class MyContext extends Context { /** + * @command testme * @args * @help Useful test! */ diff --git a/lib/Context.php b/lib/Context.php index 4ed996e..876422f 100644 --- a/lib/Context.php +++ b/lib/Context.php @@ -41,7 +41,8 @@ class Context $info[$key] = $value; } if (count($info)>0) { - $this->addCommand($method->getName(), [$this, $method->getName()], $info); + $cmdName = array_key_exists("command",$info)?$info["command"]:$method->getName(); + $this->addCommand($cmdName, [$this, $method->getName()], $info); } } } @@ -128,4 +129,4 @@ class Context return $this->data; } -} \ No newline at end of file +}