Skip to content

Instantly share code, notes, and snippets.

@etexier
Last active December 28, 2015 09:19
Show Gist options
  • Select an option

  • Save etexier/7477994 to your computer and use it in GitHub Desktop.

Select an option

Save etexier/7477994 to your computer and use it in GitHub Desktop.
A sample command
/*
* Copyright (c) 2013 Magnet Systems, Inc. All rights reserved.
*/
package com.magnet.tools.cli.test
import com.magnet.tools.cli.AbstractCommand
import com.magnet.tools.cli.Constants
/**
* Test command to verify that we can install new commands dynamically
*/
class TestCommand extends AbstractCommand {
TestCommand() {
// set name, usage, and short help (for help tool)
super('test-command', 'test-command -v', 'this is test command')
}
@Override
def execute(List<String> args) {
writer.println("this is a sample magnet command with arguments ${args}")
shell << "x curl -k -u 'magnet:password' https://localhost:8080/rest/hello?param0=${args[0]}"
getWriter().println()
return Constants.COMMAND_OK_CODE
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment