-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: remove agg binary * fix: ignore WPS232 inside `setup.py` fix: add the `build` folder to ignore * fix: add the `bin` folder to ignore * fix: fix agg path * feat: add a multiplatform agg executable * fix: fix agg path * fix: fix agg version * feat: add the `PROJECT_ROOT` constant * feat: add `LocalCommandBuilder` * feat: add functional tests * fix: fix typings * feat: now the example is using jetbrains mono * fix: remove `FontFamily` * fix: remove `FontFamily` feat: add validators for the `font_family` field * style: fix flake8 issues * test: run tests on MacOS * Update main.yml * fix: fix typo * fix: fix typo * fix: fix typo * fix: remove a windows "support" * docs: add a note for JetBrains Mono usage * fix: remove todos * docs: change `font_family` description * feat: add new WIP themes (JetBrains Light and JetBrains Dark) * fix: rename the Enter action to the Write action * docs: change the Expect action description feat: add the Control action * feat: added new actions * feat: added a new example * style: add WPS202 to ignore * deps: updated the asciinema-automation version * fix: add a default value for the timeout argument * feat: add a test for the kotlin example * fix: add a temporary noqa comment * fix: update the gifs * fix: try to fix CI * fix: try to fix CI * Update requirements.txt * Update requirements.txt * Update requirements.txt * feat: add the timeout and wait_before_loop arguments * deps: update AGG to 1.3.0 deps: bump anderson to 0.3.0 * fix: try to update gifs * fix: fix test * fix: try to fix tests * feat: add the anderson test data folder * fix: fix tests * fix: update gifs * fix: fix todo * fix: fix test data path * fix: fix gifs * fix: comment the failing test case * fix: fix links in READMEs * fix: fix the `wait_before_loop` typing
- Loading branch information
Showing
24 changed files
with
220 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import java.util.function.BinaryOperator | ||
|
||
enum class IntOperator(val symbol: String) : BinaryOperator<Int> { | ||
PLUS("+") { | ||
override fun apply(t: Int, u: Int) = t + u | ||
}, | ||
MINUS("-") { | ||
override fun apply(t: Int, u: Int) = t - u | ||
}, | ||
MULTIPLY("*") { | ||
override fun apply(t: Int, u: Int) = t * u | ||
}, | ||
DIVIDE("/") { | ||
override fun apply(t: Int, u: Int) = t / u | ||
}; | ||
|
||
companion object { | ||
fun possibleSymbols() = IntOperator.values().map { it.symbol } | ||
|
||
fun bySymbol(symbol: String) = IntOperator.values().firstOrNull { it.symbol == symbol } | ||
} | ||
} | ||
|
||
|
||
fun <T> readInput(errorMessage: String, inputConverter: (String) -> T?): T { | ||
do { | ||
val input: T? = inputConverter(readln()) | ||
input?.run { return this } | ||
println(errorMessage) | ||
} while (true) | ||
} | ||
|
||
|
||
fun main() { | ||
println("Welcome to a simple Kotlin calculator!\n") | ||
|
||
do { | ||
print("Please enter the operator (possible values: ${IntOperator.possibleSymbols().joinToString(", ")}): ") | ||
val operator = readInput( | ||
"Incorrect operator. Possible values: ${IntOperator.possibleSymbols().joinToString(", ")}.", | ||
) { IntOperator.bySymbol(it) } | ||
|
||
println() | ||
|
||
print("Please enter the left operand: ") | ||
val leftOperand = readInput("Incorrect operand. It must be an integer.") { it.toIntOrNull() } | ||
|
||
println() | ||
|
||
print("Please enter the right operand: ") | ||
val rightOperand = readInput("Incorrect operand. It must be an integer.") { it.toIntOrNull() } | ||
|
||
println() | ||
|
||
println("$leftOperand ${operator.symbol} $rightOperand = ${operator.apply(leftOperand, rightOperand)}\n") | ||
} while (true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Kotlin calculator | ||
|
||
This is a simple Kotlin calculator. | ||
|
||
Run the following command to generate GIFs: | ||
|
||
```bash | ||
anderson "kotlinc Main.kt -include-runtime -d /tmp/Main.jar && java -jar /tmp/Main.jar" ./gifs ./config.yaml | ||
``` | ||
|
||
**Note**: You need to have the `JetBrains Mono` font in your system in order for the GIFs to be generated. | ||
You can download the font [here](https://www.jetbrains.com/lp/mono/). | ||
You can also change the font in the config to any other font that is installed in your system. | ||
|
||
In the `gifs` folder you will get the following gifs: | ||
|
||
| `light.gif` | `dark.gif` | | ||
|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------| | ||
| ![light.gif](../../test/resources/anderson/kotlin_calculator/linux/light.gif) | ![dark.gif](../../test/resources/anderson/kotlin_calculator/linux/dark.gif) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
terminal_config: | ||
rows: 45 | ||
|
||
interaction_config: | ||
action_delay: 1000 | ||
|
||
gif_config: | ||
common: | ||
font_size: 32 | ||
font_family: JetBrains Mono | ||
|
||
gifs: | ||
- name: 'dark' | ||
theme: 'monokai' | ||
speed: 2 | ||
|
||
- name: 'light' | ||
theme: 'solarized_light' | ||
speed: 0.5 | ||
|
||
scenario: | ||
- expect: ": " | ||
- write: abracadabra | ||
|
||
- expect: \n | ||
- write: + | ||
|
||
- expect: ": " | ||
- write: ahalai | ||
|
||
- expect: \n | ||
- write: mahalai | ||
|
||
- expect: \n | ||
- write: 69 | ||
|
||
- expect: ": " | ||
- write: avada kedavra | ||
|
||
- expect: \n | ||
- write: 42 | ||
|
||
- expect: ": " | ||
- write: "-" | ||
|
||
- expect: ": " | ||
- write: 69 | ||
|
||
- expect: ": " | ||
- write: 42 | ||
|
||
- expect: ": " | ||
- write: "*" | ||
|
||
- expect: ": " | ||
- write: 69 | ||
|
||
- expect: ": " | ||
- write: 42 | ||
|
||
- expect: ": " | ||
- write: / | ||
|
||
- expect: ": " | ||
- write: 69 | ||
|
||
- expect: ": " | ||
- write: 42 | ||
|
||
- expect: ": " | ||
- ctrl: c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
git+https://github.com/PierreMarchand20/asciinema_automation.git@85ee2fdfc3acaa8ce1f6323ecc19d7881416e3a6#egg=asciinema-automation | ||
asciinema-automation==0.1.3 | ||
pyyaml==6.0 | ||
pydantic==1.10.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
from anderson.utils import PROJECT_ROOT | ||
|
||
EXAMPLES_FOLDER = PROJECT_ROOT / 'examples' | ||
|
||
RESOURCES_FOLDER = PROJECT_ROOT / 'test' / 'resources' | ||
|
||
ANDERSON_TEST_DATA_FOLDER = RESOURCES_FOLDER / 'anderson' |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters