Added parser test
This commit is contained in:
commit
3ec833a5bd
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
7
.idea/encodings.xml
generated
Normal file
7
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/misc.xml
generated
Normal file
14
.idea/misc.xml
generated
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
25
pom.xml
Normal file
25
pom.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>jcmd</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
23
src/main/java/de/pabulaner/jcmd/Main.java
Normal file
23
src/main/java/de/pabulaner/jcmd/Main.java
Normal file
@ -0,0 +1,23 @@
|
||||
package de.pabulaner.jcmd;
|
||||
|
||||
import de.pabulaner.jcmd.core.Line;
|
||||
import de.pabulaner.jcmd.core.Parser;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
Parser parser = null;
|
||||
|
||||
while (true) {
|
||||
String raw = scanner.nextLine();
|
||||
Line line = parser.parse(raw);
|
||||
|
||||
if (line.getCommand() != null) {
|
||||
// line.getCommand().exec(line.getFlags(), line.getArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/main/java/de/pabulaner/jcmd/command/CdCommand.java
Normal file
25
src/main/java/de/pabulaner/jcmd/command/CdCommand.java
Normal file
@ -0,0 +1,25 @@
|
||||
package de.pabulaner.jcmd.command;
|
||||
|
||||
import de.pabulaner.jcmd.core.Argument;
|
||||
import de.pabulaner.jcmd.core.Command;
|
||||
import de.pabulaner.jcmd.core.Flag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CdCommand implements Command {
|
||||
|
||||
@Override
|
||||
public int exec(List<Flag> flags, List<Argument> args) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Flag> getFlags() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
25
src/main/java/de/pabulaner/jcmd/command/HelpCommand.java
Normal file
25
src/main/java/de/pabulaner/jcmd/command/HelpCommand.java
Normal file
@ -0,0 +1,25 @@
|
||||
package de.pabulaner.jcmd.command;
|
||||
|
||||
import de.pabulaner.jcmd.core.Argument;
|
||||
import de.pabulaner.jcmd.core.Command;
|
||||
import de.pabulaner.jcmd.core.Flag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HelpCommand implements Command {
|
||||
|
||||
@Override
|
||||
public int exec(List<Flag> flags, List<Argument> args) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Flag> getFlags() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
25
src/main/java/de/pabulaner/jcmd/command/LsCommand.java
Normal file
25
src/main/java/de/pabulaner/jcmd/command/LsCommand.java
Normal file
@ -0,0 +1,25 @@
|
||||
package de.pabulaner.jcmd.command;
|
||||
|
||||
import de.pabulaner.jcmd.core.Argument;
|
||||
import de.pabulaner.jcmd.core.Command;
|
||||
import de.pabulaner.jcmd.core.Flag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LsCommand implements Command {
|
||||
|
||||
@Override
|
||||
public int exec(List<Flag> flags, List<Argument> args) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Flag> getFlags() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
25
src/main/java/de/pabulaner/jcmd/command/MkdirCommand.java
Normal file
25
src/main/java/de/pabulaner/jcmd/command/MkdirCommand.java
Normal file
@ -0,0 +1,25 @@
|
||||
package de.pabulaner.jcmd.command;
|
||||
|
||||
import de.pabulaner.jcmd.core.Argument;
|
||||
import de.pabulaner.jcmd.core.Command;
|
||||
import de.pabulaner.jcmd.core.Flag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MkdirCommand implements Command {
|
||||
|
||||
@Override
|
||||
public int exec(List<Flag> flags, List<Argument> args) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Flag> getFlags() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
14
src/main/java/de/pabulaner/jcmd/core/Argument.java
Normal file
14
src/main/java/de/pabulaner/jcmd/core/Argument.java
Normal file
@ -0,0 +1,14 @@
|
||||
package de.pabulaner.jcmd.core;
|
||||
|
||||
public class Argument {
|
||||
|
||||
private final String value;
|
||||
|
||||
public Argument(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
12
src/main/java/de/pabulaner/jcmd/core/Command.java
Normal file
12
src/main/java/de/pabulaner/jcmd/core/Command.java
Normal file
@ -0,0 +1,12 @@
|
||||
package de.pabulaner.jcmd.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Command {
|
||||
|
||||
int exec(List<Flag> flags, List<Argument> args);
|
||||
|
||||
String getName();
|
||||
|
||||
List<Flag> getFlags();
|
||||
}
|
||||
28
src/main/java/de/pabulaner/jcmd/core/Flag.java
Normal file
28
src/main/java/de/pabulaner/jcmd/core/Flag.java
Normal file
@ -0,0 +1,28 @@
|
||||
package de.pabulaner.jcmd.core;
|
||||
|
||||
public class Flag {
|
||||
|
||||
private final String shortName;
|
||||
|
||||
private final String longName;
|
||||
|
||||
private final String description;
|
||||
|
||||
public Flag(String shortName, String longName, String description) {
|
||||
this.shortName = shortName;
|
||||
this.longName = longName;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public String getLongName() {
|
||||
return longName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
57
src/main/java/de/pabulaner/jcmd/core/Line.java
Normal file
57
src/main/java/de/pabulaner/jcmd/core/Line.java
Normal file
@ -0,0 +1,57 @@
|
||||
package de.pabulaner.jcmd.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Line {
|
||||
|
||||
private final String command;
|
||||
|
||||
private final List<String> flags;
|
||||
|
||||
private final List<String> args;
|
||||
|
||||
public Line(String command, List<String> flags, List<String> args) {
|
||||
this.command = command;
|
||||
this.flags = flags;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public List<String> getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
public List<String> getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
//
|
||||
// --- Please ignore this ---
|
||||
//
|
||||
// private final Command command;
|
||||
//
|
||||
// private final List<Flag> flags;
|
||||
//
|
||||
// private final List<Argument> args;
|
||||
//
|
||||
// public Line(Command command, List<Flag> flags, List<Argument> args) {
|
||||
// this.command = command;
|
||||
// this.flags = flags;
|
||||
// this.args = args;
|
||||
// }
|
||||
//
|
||||
// public Command getCommand() {
|
||||
// return command;
|
||||
// }
|
||||
//
|
||||
// public List<Flag> getFlags() {
|
||||
// return flags;
|
||||
// }
|
||||
//
|
||||
// public List<Argument> getArgs() {
|
||||
// return args;
|
||||
// }
|
||||
}
|
||||
8
src/main/java/de/pabulaner/jcmd/core/Parser.java
Normal file
8
src/main/java/de/pabulaner/jcmd/core/Parser.java
Normal file
@ -0,0 +1,8 @@
|
||||
package de.pabulaner.jcmd.core;
|
||||
|
||||
public interface Parser {
|
||||
|
||||
void addCommand(Command command);
|
||||
|
||||
Line parse(String raw);
|
||||
}
|
||||
31
src/test/java/de/pabulaner/jcmd/core/ParserTest.java
Normal file
31
src/test/java/de/pabulaner/jcmd/core/ParserTest.java
Normal file
@ -0,0 +1,31 @@
|
||||
package de.pabulaner.jcmd.core;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class ParserTest {
|
||||
|
||||
@Test
|
||||
public void testParser() {
|
||||
Parser parser = null; // <-- Your implementation goes here
|
||||
|
||||
testInput(parser, "ls", "ls", List.of(), List.of());
|
||||
testInput(parser, "ls -la", "ls", List.of("l", "a"), List.of());
|
||||
testInput(parser, "ls ./hello/world", "ls", List.of(), List.of("./hello/world"));
|
||||
testInput(parser, "ls -la ./what", "ls", List.of("l", "a"), List.of("./what"));
|
||||
testInput(parser, "rm -r /bin /opt", "rm", List.of("r"), List.of("/bin", "/opt"));
|
||||
testInput(parser, "cd .", "cd", List.of(), List.of("."));
|
||||
testInput(parser, "mkdir .", "cd", List.of(), List.of("."));
|
||||
}
|
||||
|
||||
private void testInput(Parser parser, String input, String expectedCommand, List<String> expectedFlags, List<String> expectedArgs) {
|
||||
Line line = parser.parse(input);
|
||||
|
||||
assertEquals(expectedCommand, line.getCommand(), "Wrong command");
|
||||
assertEquals(expectedFlags, line.getFlags(), "Wrong flags");
|
||||
assertEquals(expectedArgs, line.getArgs(), "Wrong args");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user