Skip to content

Commit

Permalink
clean up comments (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo authored Jan 22, 2021
1 parent 12136e8 commit 0169883
Showing 1 changed file with 46 additions and 48 deletions.
94 changes: 46 additions & 48 deletions src/main/java/org/apache/maven/shared/utils/cli/Commandline.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,15 @@ public class Commandline
{
private final List<Arg> arguments = new Vector<Arg>();

//protected Vector envVars = new Vector();
// synchronized added to preserve synchronize of Vector class
private final Map<String, String> envVars = Collections.synchronizedMap( new LinkedHashMap<String, String>() );

private Shell shell;

/**
* Create a new command line object.
* Shell is autodetected from operating system
* @param shell The shell instance.
* Shell is autodetected from operating system.
*
* @param shell the shell instance
*/
public Commandline( Shell shell )
{
Expand All @@ -88,9 +87,9 @@ public Commandline( Shell shell )

/**
* Create a new command line object.
* Shell is autodetected from operating system
* Shell is autodetected from operating system.
*
* @param toProcess The command to process
* @param toProcess the command to process
*/
public Commandline( String toProcess ) throws CommandLineException
{
Expand All @@ -108,15 +107,15 @@ public Commandline( String toProcess ) throws CommandLineException

/**
* Create a new command line object.
* Shell is autodetected from operating system
* Shell is autodetected from operating system.
*/
public Commandline()
{
setDefaultShell();
}

/**
* <p>Sets the shell or command-line interpretor for the detected operating system,
* <p>Sets the shell or command-line interpreter for the detected operating system,
* and the shell arguments.</p>
*/
private void setDefaultShell()
Expand All @@ -140,28 +139,21 @@ private void setDefaultShell()
}

/**
* Creates an argument object.
* <p/>
* <p>Each commandline object has at most one instance of the
* argument class. This method calls
* <code>this.createArgument(false)</code>.</p>
* Creates an empty argument object and inserts it at the end of the argument list.
*
* @return the argument object.
* @return the argument object
*/
public Arg createArg()
{
return this.createArg( false );
}

/**
* Creates an argument object and adds it to our list of args.
* <p/>
* <p>Each commandline object has at most one instance of the
* argument class.</p>
* Creates an argument object and adds it to the list of args.
*
* @param insertAtStart if true, the argument is inserted at the
* beginning of the list of args, otherwise it is appended.
* @return The arguments.
* beginning of the list of args. Otherwise it is appended.
* @return the argument
*/
public Arg createArg( boolean insertAtStart )
{
Expand All @@ -179,15 +171,16 @@ public Arg createArg( boolean insertAtStart )

/**
* Sets the executable to run.
* @param executable The executable.
*
* @param executable the executable
*/
public void setExecutable( String executable )
{
shell.setExecutable( executable );
}

/**
* @return The executable.
* @return the executable
*/
public String getExecutable()
{
Expand All @@ -196,7 +189,7 @@ public String getExecutable()
}

/**
* @param line The arguments.
* @param line the arguments
*/
public void addArguments( String... line )
{
Expand All @@ -207,9 +200,10 @@ public void addArguments( String... line )
}

/**
* Add an environment variable
* @param name The name of the environment variable.
* @param value The appropriate value.
* Add an environment variable.
*
* @param name the name of the environment variable
* @param value the appropriate value
*/
public void addEnvironment( String name, String value )
{
Expand All @@ -218,7 +212,7 @@ public void addEnvironment( String name, String value )
}

/**
* Add system environment variables
* Add system environment variables.
*/
public void addSystemEnvironment()
{
Expand All @@ -235,8 +229,9 @@ public void addSystemEnvironment()
}

/**
* Return the list of environment variables
* @return an array of all environment variables.
* Return the list of environment variables.
*
* @return an array of all environment variables
*/
public String[] getEnvironmentVariables()
{
Expand All @@ -254,7 +249,8 @@ public String[] getEnvironmentVariables()

/**
* Returns the executable and all defined arguments.
* @return an array of all arguments incl. executable.
*
* @return an array of all arguments including the executable
*/
public String[] getCommandline()
{
Expand All @@ -272,15 +268,15 @@ public String[] getCommandline()
}

/**
* @return the shell, executable and all defined arguments without masking any arguments.
* @return the shell, executable and all defined arguments without masking any arguments
*/
private String[] getShellCommandline()
{
return getShellCommandline( false ) ;
}

/**
* @param mask flag to mask any arguments (having his {@code mask} field to {@code true}).
* @param mask flag to mask any arguments (having his {@code mask} field to {@code true})
* @return the shell, executable and all defined arguments with masking some arguments if
* {@code mask} parameter is on
*/
Expand All @@ -302,10 +298,10 @@ public String[] getArguments()

/**
* Returns all arguments defined by <code>addLine</code>,
* <code>addValue</code> or the argument object.
* <code>addValue</code>, or the argument object.
*
* @param mask flag to mask any arguments (having his {@code mask} field to {@code true}).
* @return an array of arguments.
* @param mask flag to mask any arguments (having his {@code mask} field to {@code true})
* @return an array of arguments
*/
public String[] getArguments( boolean mask )
{
Expand Down Expand Up @@ -355,24 +351,26 @@ public Object clone()

/**
* Sets working directory.
* @param path The to be set as working directory.
*
* @param path the working directory
*/
public void setWorkingDirectory( String path )
{
shell.setWorkingDirectory( path );
}

/**
* Sets execution directory.
* @param workingDirectory The working directory.
* Sets working directory.
*
* @param workingDirectory the working directory
*/
public void setWorkingDirectory( File workingDirectory )
{
shell.setWorkingDirectory( workingDirectory );
}

/**
* @return The working directory.
* @return the working directory
*/
public File getWorkingDirectory()
{
Expand All @@ -388,17 +386,16 @@ public void clearArgs()
}

/**
* Executes the command.
* @return The process.
* @throws CommandLineException in case of errors.
* Execute the command.
*
* @return the process
* @throws CommandLineException in case of errors
*/
public Process execute()
throws CommandLineException
{
Process process;

//addEnvironment( "MAVEN_TEST_ENVAR", "MAVEN_TEST_ENVAR_VALUE" );

String[] environment = getEnvironmentVariables();

File workingDir = shell.getWorkingDirectory();
Expand Down Expand Up @@ -434,7 +431,7 @@ else if ( !workingDir.isDirectory() )
}

/**
* Allows to set the shell to be used in this command line.
* Set the shell to be used for this command line.
*
* @param shell the shell
*/
Expand All @@ -445,15 +442,16 @@ void setShell( Shell shell )

/**
* Get the shell to be used in this command line.
* @return the shell.
*
* @return the shell
*/
public Shell getShell()
{
return shell;
}

/**
*
* A single command line argument
*/
public static class Argument
implements Arg
Expand Down Expand Up @@ -502,7 +500,7 @@ public void setMask( boolean mask )
}

/**
* @return The parts.
* @return the parts
*/
private String[] getParts()
{
Expand Down

0 comments on commit 0169883

Please sign in to comment.