mil.dod.th.ose.sdk/src/mil/dod/th/ose/sdk/those/ThoseMain.java
private static void processSubcommand(final String subcmd, final OptionSet options)
            throws Exception
    {
        final List<String> nonOptions = options.nonOptionArguments();

        final ProjectProperties props = new ProjectProperties(new BndService());

        // Check for a correct sub-command
        if ("create".equals(subcmd))
        {
            //figure out project type and class name
            setProjectTypeAndClassName(options, props);
            
            //figure out physical link type 
            setPhysicalLinkTypeEnum(options, props);
            
            // optionally, the package name can be set from the command line
            if (options.hasArgument(OPTION_PACKAGE_NAME))
            {
                props.setPackageName((String)options.valueOf(OPTION_PACKAGE_NAME));
            }

            // Retrieve the path where the SDK is located.
            final String sdkDir = new File(ThoseMain.class.getProtectionDomain()
                    .getCodeSource().getLocation().getPath()).getParentFile().getParent();
            final String sdkDirErr = "\nInvalid project directory. Please select a directory besides "
                    + "the one the SDK is located in.";
            
            // Check if the user specified a project directory, otherwise use the current directory
            final Path projectDir;
            if (nonOptions.size() > 1)
            {
                projectDir = Paths.get(nonOptions.get(1));
                // Verify the user specified directory is not the same directory the SDK is located in.
                if (sdkDir.equals(projectDir.toFile().getCanonicalPath()))
                {
                    final Exception error = new IllegalArgumentException(sdkDirErr);
                    checkVerbose(error, options);
                    OUT_STREAM.println(sdkDirErr);
                    System.exit(1);
                }
            }
            else
            {
                final Path cwd = Paths.get(System.getProperty("user.dir"));
                // Verify the current directory is not the same directory the SDK is located in.
                if (sdkDir.equals(cwd.toFile().getCanonicalPath()))
                {
                    final Exception error = new IllegalArgumentException(sdkDirErr);
                    checkVerbose(error, options);
                    OUT_STREAM.println(sdkDirErr);
                    System.exit(1);
                }
                projectDir = cwd;
            }

            // Ask the user for input on project properties if the default option was not used
            if (!options.has(OPTION_DEFAULT_PROPS))
            {
                getProjectProperties(props, options.hasArgument(OPTION_PACKAGE_NAME), 
                        options.hasArgument(OPTION_PHYS_LINK_TYPE));
            }

            // Create the new project
            createProject(props, projectDir);
        }
        else if ("help".equals(subcmd))
        {
            OUT_STREAM.println(getUsage());
        }
        else if ("version".equals(subcmd))
        {
            try
            {
                OUT_STREAM.format("API Version: %s%n", props.getApiVersion());
            }
            catch (final Exception error)
            {
                checkVerbose(error, options);
                OUT_STREAM.println("\nError retrieving the API verision");
            }
        }  
        else
        {
            final String invalidSub = "\nInvalid sub-command\n" + getUsage();
            final Exception error = new IllegalArgumentException(invalidSub);
            checkVerbose(error, options);
            OUT_STREAM.print(invalidSub);
        }
    }
/**
     * Process and handle the given sub-command.
     * 
     * @param subcmd
     *            sub command given by the user
     * @param options
     *            options parsed from the command line
     * @throws Exception 
     *            IllegalArgumentExceptions if there is a bad argument. 
     *            Also throws an exception if API version isn't retrieved.
     */
Process and handle the given sub-command.

@param subcmd
sub command given by the user
@param options
options parsed from the command line
@throws Exception
IllegalArgumentExceptions if there is a bad argument.
Also throws an exception if API version isn't retrieved.
Process and handle the given sub - command . @param subcmd sub command given by the user @param options options parsed from the command line @throws Exception IllegalArgumentExceptions if there is a bad argument . Also throws an exception if API version isn ' t retrieved .
private static void processSubcommand(final String subcmd, final OptionSet options)
            throws Exception
    {
        final List<String> nonOptions = options.nonOptionArguments();
        final ProjectProperties props = new ProjectProperties(new BndService());
        if ("create".equals(subcmd))
        {
            setProjectTypeAndClassName(options, props);
            setPhysicalLinkTypeEnum(options, props);
            if (options.hasArgument(OPTION_PACKAGE_NAME))
            {
                props.setPackageName((String)options.valueOf(OPTION_PACKAGE_NAME));
            }
            final String sdkDir = new File(ThoseMain.class.getProtectionDomain()
                    .getCodeSource().getLocation().getPath()).getParentFile().getParent();
            final String sdkDirErr = "\nInvalid project directory. Please select a directory besides "
                    + "the one the SDK is located in.";
            final Path projectDir;
            if (nonOptions.size() > 1)
            {
                projectDir = Paths.get(nonOptions.get(1));
                if (sdkDir.equals(projectDir.toFile().getCanonicalPath()))
                {
                    final Exception error = new IllegalArgumentException(sdkDirErr);
                    checkVerbose(error, options);
                    OUT_STREAM.println(sdkDirErr);
                    System.exit(1);
                }
            }
            else
            {
                final Path cwd = Paths.get(System.getProperty("user.dir"));
                if (sdkDir.equals(cwd.toFile().getCanonicalPath()))
                {
                    final Exception error = new IllegalArgumentException(sdkDirErr);
                    checkVerbose(error, options);
                    OUT_STREAM.println(sdkDirErr);
                    System.exit(1);
                }
                projectDir = cwd;
            }
            if (!options.has(OPTION_DEFAULT_PROPS))
            {
                getProjectProperties(props, options.hasArgument(OPTION_PACKAGE_NAME), 
                        options.hasArgument(OPTION_PHYS_LINK_TYPE));
            }
            createProject(props, projectDir);
        }
        else if ("help".equals(subcmd))
        {
            OUT_STREAM.println(getUsage());
        }
        else if ("version".equals(subcmd))
        {
            try
            {
                OUT_STREAM.format("API Version: %s%n", props.getApiVersion());
            }
            catch (final Exception error)
            {
                checkVerbose(error, options);
                OUT_STREAM.println("\nError retrieving the API verision");
            }
        }  
        else
        {
            final String invalidSub = "\nInvalid sub-command\n" + getUsage();
            final Exception error = new IllegalArgumentException(invalidSub);
            checkVerbose(error, options);
            OUT_STREAM.print(invalidSub);
        }
    }
private static void processSubcommand ( final String subcmd , final OptionSet options ) throws Exception { final List < String > nonOptions = options . nonOptionArguments ( ) ; final ProjectProperties props = new ProjectProperties ( new BndService ( ) ) ; if ( "create" . equals ( subcmd ) ) { setProjectTypeAndClassName ( options , props ) ; setPhysicalLinkTypeEnum ( options , props ) ; if ( options . hasArgument ( OPTION_PACKAGE_NAME ) ) { props . setPackageName ( ( String ) options . valueOf ( OPTION_PACKAGE_NAME ) ) ; } final String sdkDir = new File ( ThoseMain . class . getProtectionDomain ( ) . getCodeSource ( ) . getLocation ( ) . getPath ( ) ) . getParentFile ( ) . getParent ( ) ; final String sdkDirErr = "\nInvalid project directory. Please select a directory besides " + "the one the SDK is located in." ; final Path projectDir ; if ( nonOptions . size ( ) > 1 ) { projectDir = Paths . get ( nonOptions . get ( 1 ) ) ; if ( sdkDir . equals ( projectDir . toFile ( ) . getCanonicalPath ( ) ) ) { final Exception error = new IllegalArgumentException ( sdkDirErr ) ; checkVerbose ( error , options ) ; OUT_STREAM . println ( sdkDirErr ) ; System . exit ( 1 ) ; } } else { final Path cwd = Paths . get ( System . getProperty ( "user.dir" ) ) ; if ( sdkDir . equals ( cwd . toFile ( ) . getCanonicalPath ( ) ) ) { final Exception error = new IllegalArgumentException ( sdkDirErr ) ; checkVerbose ( error , options ) ; OUT_STREAM . println ( sdkDirErr ) ; System . exit ( 1 ) ; } projectDir = cwd ; } if ( ! options . has ( OPTION_DEFAULT_PROPS ) ) { getProjectProperties ( props , options . hasArgument ( OPTION_PACKAGE_NAME ) , options . hasArgument ( OPTION_PHYS_LINK_TYPE ) ) ; } createProject ( props , projectDir ) ; } else if ( "help" . equals ( subcmd ) ) { OUT_STREAM . println ( getUsage ( ) ) ; } else if ( "version" . equals ( subcmd ) ) { try { OUT_STREAM . format ( "API Version: %s%n" , props . getApiVersion ( ) ) ; } catch ( final Exception error ) { checkVerbose ( error , options ) ; OUT_STREAM . println ( "\nError retrieving the API verision" ) ; } } else { final String invalidSub = "\nInvalid sub-command\n" + getUsage ( ) ; final Exception error = new IllegalArgumentException ( invalidSub ) ; checkVerbose ( error , options ) ; OUT_STREAM . print ( invalidSub ) ; } }
Process and handle the given sub-command.
Process and handle the given sub - command .
// Check for a correct sub-command //figure out project type and class name //figure out physical link type  // optionally, the package name can be set from the command line // Retrieve the path where the SDK is located. // Check if the user specified a project directory, otherwise use the current directory // Verify the user specified directory is not the same directory the SDK is located in. // Verify the current directory is not the same directory the SDK is located in. // Ask the user for input on project properties if the default option was not used // Create the new project