How To Get Action Name In Cconsolecommand?

How to get action name ‘Show’ in CConsoleCommand?If I need to get the action name from FUNCTION or init a public varible in beforeAction()?


class TestCommand extends CConsoleCommand{

    public $action;


    protected function beforeAction($action, $params) {

	$this->action = $action;

	return parent::beforeAction($action, $params);



    public function actionShow(){




just trim the word action

var_dump(ltrim(__FUNCTION__, "action"));