vertx-shell unregister built-in commands?

56 views
Skip to first unread message

Grant Haywood

unread,
Jul 28, 2016, 2:23:47 AM7/28/16
to vert.x
when using vertx-shell, I have a small groovy block that goes like this:

def reg = CommandRegistry.getShared(vertx)
["echo","sleep","cd","pwd","ls"].each{ String cmd ->
reg.unregisterCommand(cmd)
}


however I still see the commands in the shell, Is unregistering commands supported?

% help                                                                                                                  
available commands:                                                                                                     
echo                                                                                                                    
sleep                                                                                                                   
help                                                                                                                    
cd                                                                                                                      
pwd                                                                                                                     
ls                                                                                                                      
net-ls                                                                                                                  
local-map-get                                                                                                           
local-map-put                                                                                                           
local-map-rm                                                                                                            
bus-publish                                                                                                             
bus-send                                                                                                                
bus-tail                                                                                                                
verticle-ls                                                                                                             
verticle-deploy                                                                                                         
verticle-undeploy                                                                                                       
verticle-factories                                                                                                      
setup                                                                                                                   
component                                                                                                               
exit                                                                                                                    
logout                                                                                                                  
jobs                                                                                                                    
fg                                                                                                                      
bg          

Julien Viet

unread,
Jul 28, 2016, 3:46:19 AM7/28/16
to ve...@googlegroups.com
can you try with the unregisterCommand version that has an Handler<AsyncResult<Void>> to see if an error happens or not ?


--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/1b4bd19a-0a0e-4070-b107-582050471b8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Grant Haywood

unread,
Jul 28, 2016, 1:35:07 PM7/28/16
to vert.x
Thanks for the reply

now my groovy block looks like this:


        ["echo", "sleep", "cd", "pwd", "ls"].each { String cmd ->
            reg.unregisterCommand(cmd, { AsyncResult res ->
                if(res.failed())
                    logger.error(res.cause())
            })
        }

and the relevant output looks like:

io.vertx.core.impl.NoStackTraceThrowable: Command echo not registered
io.vertx.core.impl.NoStackTraceThrowable: Command sleep not registered
io.vertx.core.impl.NoStackTraceThrowable: Command cd not registered
io.vertx.core.impl.NoStackTraceThrowable: Command pwd not registered
io.vertx.core.impl.NoStackTraceThrowable: Command ls not registered

Julien Viet

unread,
Jul 28, 2016, 4:43:55 PM7/28/16
to ve...@googlegroups.com
can you share the entire code, i.e how you create the shell and its connectors

Grant Haywood

unread,
Jul 28, 2016, 6:24:47 PM7/28/16
to ve...@googlegroups.com
shadowJar should produce an executable jar that runs that file



Julien Viet

unread,
Jul 30, 2016, 3:22:22 AM7/30/16
to ve...@googlegroups.com
Hi Grant,

this happens because the ShellService adds the BaseCommandPack to the underlying ShellServer separately, so the BaseCommandPack and the CommandRegistry are both added in the ShellServer using the registerCommandResolver().

in your case if you want to fine grained control what goes in your server, you need to build rather a ShellServer and start it instead of using the ShellService, for example:

CommandRegistry register = ….; // Create appropriate command registry
ShellServer server = ShellServer.create(vertx, shellServerOptions);
server.registerTermServer(new TelnetTermServer(vertx, telnetOptions));
server.registerCommandResolver(commandRegistry);
server.listen();

cheers

Julien

Grant Haywood

unread,
Jul 30, 2016, 3:48:57 AM7/30/16
to ve...@googlegroups.com
oh interesting, thank you for the tip!

I have another question, if you dont mind, is there any way to get the user name that authenticated (via properties or ldap or similar) from the CommandProcess  or Session  inside a command?

Julien Viet

unread,
Jul 30, 2016, 3:51:31 AM7/30/16
to ve...@googlegroups.com
I think it should be added to the to the Session interface.

do you mind contribute this feature ?

Grant Haywood

unread,
Jul 30, 2016, 3:52:25 AM7/30/16
to ve...@googlegroups.com
well, I am better at Groovy then Java, but ill give it a try !

Reply all
Reply to author
Forward
0 new messages