-
Notifications
You must be signed in to change notification settings - Fork 1
HW01 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
HW01 #4
Changes from 8 commits
f96dcd1
c8fd1cf
cf01396
33f7668
119060f
b694206
9a1ae7c
e7408b8
2a3adab
260ae77
5ab0470
55fb90a
105b74d
c823875
33ec1d1
9f7155b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: CI | ||
| on: [push] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v2 | ||
| with: | ||
| java-version: 17 | ||
| distribution: 'adopt' | ||
| - name: Build with Gradle | ||
| run: ./gradlew build | ||
| - name: Test with Gradle | ||
| run: ./gradlew test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,19 @@ | ||
| # sd-homework | ||
| # simplecli | ||
|
|
||
| Implemented build-ins: | ||
| - [cat](src/main/java/ru/itmo/simplecli/executor/constructors/Cat.java) | ||
| - [echo](src/main/java/ru/itmo/simplecli/executor/constructors/Echo.java) | ||
| - [exit](src/main/java/ru/itmo/simplecli/executor/constructors/Exit.java) | ||
| - [grep](src/main/java/ru/itmo/simplecli/executor/constructors/Grep.java) | ||
| - [pwd](src/main/java/ru/itmo/simplecli/executor/constructors/Pwd.java) | ||
| - [wc](src/main/java/ru/itmo/simplecli/executor/constructors/WC.java) | ||
| - [variable assignment](src/main/java/ru/itmo/simplecli/executor/constructors/Assignment.java) | ||
|
|
||
| [Main](src/main/java/ru/itmo/simplecli/Main.java) runs loop until `exit` command is given. | ||
| If the entered string contains incomplete quotes, it asks to continue typing. | ||
|
|
||
| [Parser](src/main/java/ru/itmo/simplecli/executor/Parser.java) supports double and single quotes. | ||
| It also performs substitution for values beginning with `$` if it is not surrounded by single quotes. | ||
|
|
||
| The CLI [supports](src/main/java/ru/itmo/simplecli/executor/PipedCommand.java) a pipeline of commands, separated by a sign `|`, | ||
| each command receives as input the output of the previous one. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| plugins { | ||
| java | ||
| } | ||
|
|
||
| group = "org.example" | ||
|
||
| version = "1.0-SNAPSHOT" | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation("commons-cli:commons-cli:1.5.0") | ||
| testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") | ||
| testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") | ||
| } | ||
|
|
||
| java { | ||
| toolchain { | ||
| languageVersion.set(JavaLanguageVersion.of(17)) | ||
| } | ||
| } | ||
|
|
||
| tasks.test { | ||
| useJUnitPlatform() | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| rootProject.name = "simplecli" | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package ru.itmo.simplecli; | ||
|
|
||
| import ru.itmo.simplecli.executor.*; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| /** | ||
| * Entry point. Loop: read - parse - execute. | ||
| */ | ||
| public class Main { | ||
| public static void main(String[] args) { | ||
| Scanner scanner = new Scanner(System.in); | ||
| EnvironmentManager environment = new EnvironmentManager(); | ||
| Parser parser = new Parser(environment); | ||
|
|
||
| while (true) { | ||
| System.out.print(">> "); | ||
| String input = scanner.nextLine(); | ||
| if (input.trim().equals("")) { | ||
| continue; | ||
| } | ||
|
|
||
| parser.parse(input); | ||
| while (parser.hasUnclosedQuote()) { | ||
| System.out.print("> "); | ||
| input = input + scanner.nextLine(); | ||
| parser.parse(input); | ||
| } | ||
|
|
||
| var command = PipedCommandFactory.construct(parser.getResult(), environment); | ||
| if (command == null) { | ||
| System.out.println("Can't construct command"); | ||
| continue; | ||
| } | ||
|
|
||
| command.execute(null); | ||
| if (command.getEndStatus() == Executable.EndStatus.EXIT) { | ||
| break; | ||
| } | ||
| if (command.getOutput() != null) { | ||
| System.out.println(command.getOutput()); | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не хватает только инструкции по запуску.
-0.5.