You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Christophe Vanfleteren (JIRA)" <ji...@apache.org> on 2013/06/29 00:13:20 UTC

[jira] [Commented] (KARAF-2370) Add alias command

    [ https://issues.apache.org/jira/browse/KARAF-2370?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13695861#comment-13695861 ] 

Christophe Vanfleteren commented on KARAF-2370:
-----------------------------------------------

Warning: Karaf newbie speaking here.

The alias command itself is extremely simple, something like the following would do:

{code:title=AliasAction.java|borderStyle=solid}
@Command(scope = "shell", name = "alias", description = "Alias a command")
public class AliasAction extends AbstractAction {

    @Argument(index = 0, name="command", description = "The command to alias, eg 'ldn = { log:display -n $args }'", required = true, multiValued = false)
    private String alias;

    protected Object doExecute() throws Exception {
        session.execute(alias);

        return null;
    }

}
{code} 


The hard part is the behaviour around the persistence in the shell.init.script file.
Adding a new alias is quite simple, just append the entered line to the end of the file. But what happens if you redefine an alias? Do we keep the previous version in the file also? Do we remove it? 
Do we remove the alias in the shell.init.script file when you call {{alias ldn=''}} after calling {{alias 'ldn = \{ log:display -n $args\}'}}? Do we always save/remove the aliases or is it an explicit option?

Removing aliases means parsing the script file to find a line that matches and remove it. What if there already was more than one line defining that alias? Do you delete the last? The first? All of them? 


                
> Add alias command
> -----------------
>
>                 Key: KARAF-2370
>                 URL: https://issues.apache.org/jira/browse/KARAF-2370
>             Project: Karaf
>          Issue Type: New Feature
>          Components: karaf-shell
>            Reporter: Jean-Baptiste Onofré
>            Assignee: Jean-Baptiste Onofré
>             Fix For: 2.3.2, 2.4.0, 3.0.0
>
>
> Currently, it's possible to create shell aliases by editing etc/shell.init.script. However, we don't provide a command to create aliases "on the fly", like alias on Unix.
> The alias command should enhance the shell console with new aliases and update the etc/shell.init.script file.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira