Example usage for org.apache.commons.cli CommandLine getArgs

List of usage examples for org.apache.commons.cli CommandLine getArgs

Introduction

In this page you can find the example usage for org.apache.commons.cli CommandLine getArgs.

Prototype

public String[] getArgs() 

Source Link

Document

Retrieve any left-over non-recognized options and arguments

Usage

From source file:com.netscape.cmstools.tps.profile.ProfileMappingRemoveCLI.java

public void execute(String[] args) throws Exception {
    // Always check for "--help" prior to parsing
    if (Arrays.asList(args).contains("--help")) {
        printHelp();//from w w  w  .  ja v  a2  s .c om
        return;
    }

    CommandLine cmd = parser.parse(options, args);

    String[] cmdArgs = cmd.getArgs();

    if (cmdArgs.length != 1) {
        throw new Exception("No Profile Mapping ID specified.");
    }

    String profileMappingID = args[0];

    ProfileMappingClient profileMappingClient = profileMappingCLI.getProfileMappingClient();
    profileMappingClient.removeProfileMapping(profileMappingID);

    MainCLI.printMessage("Deleted profile mapping \"" + profileMappingID + "\"");
}

From source file:com.netscape.cmstools.tps.profile.ProfileRemoveCLI.java

public void execute(String[] args) throws Exception {
    // Always check for "--help" prior to parsing
    if (Arrays.asList(args).contains("--help")) {
        printHelp();//  w ww .  java2  s . co  m
        return;
    }

    CommandLine cmd = parser.parse(options, args);

    String[] cmdArgs = cmd.getArgs();

    if (cmdArgs.length != 1) {
        throw new Exception("No Profile ID specified.");
    }

    String profileID = args[0];

    ProfileClient profileClient = profileCLI.getProfileClient();
    profileClient.removeProfile(profileID);

    MainCLI.printMessage("Deleted profile \"" + profileID + "\"");
}

From source file:com.netscape.cmstools.tps.token.TokenRemoveCLI.java

public void execute(String[] args) throws Exception {
    // Always check for "--help" prior to parsing
    if (Arrays.asList(args).contains("--help")) {
        printHelp();/*from w  w w.  j  a va 2s. c  om*/
        return;
    }

    CommandLine cmd = parser.parse(options, args);

    String[] cmdArgs = cmd.getArgs();

    if (cmdArgs.length != 1) {
        throw new Exception("No Token ID specified.");
    }

    String tokenID = args[0];

    TokenClient tokenClient = tokenCLI.getTokenClient();
    tokenClient.removeToken(tokenID);

    MainCLI.printMessage("Deleted token \"" + tokenID + "\"");
}

From source file:com.netscape.cmstools.user.UserRemoveCLI.java

public void execute(String[] args) throws Exception {
    // Always check for "--help" prior to parsing
    if (Arrays.asList(args).contains("--help")) {
        printHelp();/*  ww w.  j  a va 2s  .c  o m*/
        return;
    }

    CommandLine cmd = parser.parse(options, args);

    String[] cmdArgs = cmd.getArgs();

    if (cmdArgs.length != 1) {
        throw new Exception("No User ID specified.");
    }

    String userID = args[0];

    UserClient userClient = userCLI.getUserClient();
    userClient.removeUser(userID);

    MainCLI.printMessage("Deleted user \"" + userID + "\"");
}

From source file:alluxio.cli.fs.command.MkdirCommand.java

@Override
public int run(CommandLine cl) throws AlluxioException, IOException {
    String[] args = cl.getArgs();
    for (String path : args) {
        AlluxioURI inputPath = new AlluxioURI(path);

        CreateDirectoryOptions options = CreateDirectoryOptions.defaults().setRecursive(true);
        mFileSystem.createDirectory(inputPath, options);
        System.out.println("Successfully created directory " + inputPath);
    }/*from w ww .j a va2s  .  c om*/
    return 0;
}

From source file:com.netscape.cmstools.group.GroupMemberRemoveCLI.java

public void execute(String[] args) throws Exception {
    // Always check for "--help" prior to parsing
    if (Arrays.asList(args).contains("--help")) {
        printHelp();//from   w  ww  .j av a 2 s.c o  m
        return;
    }

    CommandLine cmd = parser.parse(options, args);

    String[] cmdArgs = cmd.getArgs();

    if (cmdArgs.length != 2) {
        throw new Exception("Incorrect number of arguments specified.");
    }

    String groupID = cmdArgs[0];
    String memberID = cmdArgs[1];

    GroupClient groupClient = groupMemberCLI.getGroupClient();
    groupClient.removeGroupMember(groupID, memberID);

    MainCLI.printMessage("Deleted group member \"" + memberID + "\"");
}

From source file:com.netscape.cmstools.user.UserMembershipRemoveCLI.java

public void execute(String[] args) throws Exception {
    // Always check for "--help" prior to parsing
    if (Arrays.asList(args).contains("--help")) {
        printHelp();//from w w w .  j  a  va2 s  .co m
        return;
    }

    CommandLine cmd = parser.parse(options, args);

    String[] cmdArgs = cmd.getArgs();

    if (cmdArgs.length != 2) {
        throw new Exception("Incorrect number of arguments specified.");
    }

    String userID = args[0];
    String groupID = args[1];

    UserClient userClient = userMembershipCLI.getUserClient();
    userClient.removeUserMembership(userID, groupID);

    MainCLI.printMessage("Deleted membership in group \"" + groupID + "\"");
}

From source file:com.netscape.cmstools.feature.FeatureShowCLI.java

public void execute(String[] args) throws Exception {
    // Always check for "--help" prior to parsing
    if (Arrays.asList(args).contains("--help")) {
        printHelp();/*from   w w w  .jav  a  2  s  .  com*/
        return;
    }

    CommandLine cmd = parser.parse(options, args);

    String[] cmdArgs = cmd.getArgs();

    if (cmdArgs.length > 1) {
        throw new Exception("Too many arguments.");
    }

    if (cmdArgs.length == 0) {
        throw new Exception("No ID specified.");
    }

    String featureID = cmdArgs[0];

    FeatureClient featureClient = featureCLI.getFeatureClient();
    Feature data = featureClient.getFeature(featureID);
    FeatureCLI.printFeature(data);
}

From source file:alluxio.cli.fsadmin.command.BackupCommand.java

@Override
public int run(CommandLine cl) throws IOException {
    String[] args = cl.getArgs();
    String dir;/*from   w  ww.ja  va 2s.  c  om*/
    if (args.length < 1) {
        dir = null;
    } else {
        dir = args[0];
    }
    boolean local = cl.hasOption(LOCAL_OPTION.getLongOpt());
    BackupResponse resp = mMetaClient.backup(dir, local);
    if (local) {
        mPrintStream.printf("Successfully backed up journal to %s on master %s%n", resp.getBackupUri(),
                resp.getHostname());
    } else {
        mPrintStream.printf("Successfully backed up journal to %s%n", resp.getBackupUri());
    }
    return 0;
}

From source file:com.netscape.cmstools.group.GroupShowCLI.java

public void execute(String[] args) throws Exception {
    // Always check for "--help" prior to parsing
    if (Arrays.asList(args).contains("--help")) {
        printHelp();//from  w w  w.j  a  va2  s  .co  m
        return;
    }

    CommandLine cmd = parser.parse(options, args);

    String[] cmdArgs = cmd.getArgs();

    if (cmdArgs.length != 1) {
        throw new Exception("No Group ID specified.");
    }

    String groupID = cmdArgs[0];

    GroupClient groupClient = groupCLI.getGroupClient();
    GroupData groupData = groupClient.getGroup(groupID);

    MainCLI.printMessage("Group \"" + groupID + "\"");

    GroupCLI.printGroup(groupData);
}