<?php

namespace Clue\PharComposer;

use Symfony\Component\Console\Application as BaseApplication;

class App extends BaseApplication
{
    public function __construct()
    {
        parent::__construct('phar-composer', '@git_tag@');

        $this->add(new Command\Build());
        $this->add(new Command\Search());
        $this->add(new Command\Install());
        $this->add(new Command\Gui());
    }
}

<?php

namespace Clue\PharComposer;

use Symfony\Component\Console\Application as BaseApplication;
use Symfony\Component\Console\Input\InputInterface;

class App extends BaseApplication
{
    private $isDefault = false;

    public function __construct()
    {
        parent::__construct('phar-composer', '@git_tag@');

        $this->add(new Command\Build());
        $this->add(new Command\Search());
        $this->add(new Command\Install());
        $this->add(new Command\Gui());
    }

    /**
     * Gets the name of the command based on input.
     *
     * @param InputInterface $input The input interface
     *
     * @return string The command name
     */
    protected function getCommandName(InputInterface $input)
    {
        if ($input->getFirstArgument() === null && !$input->hasParameterOption(array('--help', '-h'))) {
            $this->isDefault = true;
            return $this->getDefaultCommandName();
        }
        return parent::getCommandName($input);
    }

    private function getDefaultCommandName()
    {
        return 'search';
    }

    /**
     * Overridden so that the application doesn't expect the command
     * name to be the first argument.
     */
    public function getDefinition()
    {
        $inputDefinition = parent::getDefinition();

        if ($this->isDefault) {
            // clear out the normal first argument, which is the command name
            $inputDefinition->setArguments();
        }

        return $inputDefinition;
    }
}

Add default command name 'search' it nothing was given
Add default command name 'search' it nothing was given