Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 120
tab_width = 8
16 changes: 16 additions & 0 deletions .github/workflows/gradle.yml
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
.gradle
.idea
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# sd-homework
# simplecli

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не хватает только инструкции по запуску. -0.5.


### How to run

Run [main](src/main/java/ru/itmo/simplecli/Main.java)
method from IDE **or** `./gradlew run`.

### What's there

Implemented build-ins:
- [cat](src/main/java/ru/itmo/simplecli/executor/commands/Cat.java)
- [echo](src/main/java/ru/itmo/simplecli/executor/commands/Echo.java)
- [exit](src/main/java/ru/itmo/simplecli/executor/commands/Exit.java)
- [pwd](src/main/java/ru/itmo/simplecli/executor/commands/Pwd.java)
- [wc](src/main/java/ru/itmo/simplecli/executor/commands/WC.java)
- [variable assignment](src/main/java/ru/itmo/simplecli/executor/commands/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.
34 changes: 34 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
application
}

application {
mainClass.set("ru.itmo.simplecli.Main")
}

group = "ru.itmo"
version = "1.0"

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()
}

tasks.named<JavaExec>("run") {
standardInput = System.`in`
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
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
185 changes: 185 additions & 0 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rootProject.name = "simplecli"

Loading