mirror of
https://github.com/Paillat-dev/hello-world-scala.git
synced 2026-01-01 16:56:21 +00:00
First commit
This commit is contained in:
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# sbt specific
|
||||
dist/*
|
||||
target/
|
||||
lib_managed/
|
||||
src_managed/
|
||||
project/boot/
|
||||
project/plugins/project/
|
||||
project/local-plugins.sbt
|
||||
.history
|
||||
.ensime
|
||||
.ensime_cache/
|
||||
.sbt-scripted/
|
||||
local.sbt
|
||||
|
||||
# Bloop
|
||||
.bsp
|
||||
|
||||
# VS Code
|
||||
.vscode/
|
||||
|
||||
# Metals
|
||||
.bloop/
|
||||
.metals/
|
||||
metals.sbt
|
||||
|
||||
# IDEA
|
||||
.idea
|
||||
.idea_modules
|
||||
/.worksheet/
|
||||
11
.scalafix.conf
Normal file
11
.scalafix.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
rules = [
|
||||
RemoveUnused,
|
||||
DisableSyntax,
|
||||
LeakingImplicitClassVal,
|
||||
NoValInForComprehension,
|
||||
ProcedureSyntax,
|
||||
RedundantSyntax,
|
||||
OrganizeImports,
|
||||
NoAutoTupling,
|
||||
ExplicitResultTypes
|
||||
]
|
||||
5
.scalafmt.conf
Normal file
5
.scalafmt.conf
Normal file
@@ -0,0 +1,5 @@
|
||||
version = 3.9.8
|
||||
runner.dialect = scala3
|
||||
|
||||
align.preset = more
|
||||
maxColumn = 120
|
||||
26
README.md
Normal file
26
README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Scala hello world
|
||||
|
||||
This is my take at a hello world in Scala. It prints a colored "Hello, World!" message to the console.
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
This project uses [sbt](https://www.scala-sbt.org/) as the build tool. To run the project, you can use the following command:
|
||||
|
||||
```bash
|
||||
sbt run
|
||||
```
|
||||
|
||||
## Requirements
|
||||
- [Eclipse Temurin](https://adoptium.net/) or any other JDK 17+ installed on your system
|
||||
- [sbt](https://www.scala-sbt.org/) for building and running the project
|
||||
- [Scala](https://www.scala-lang.org/) installed on your system
|
||||
|
||||
## Dependencies
|
||||
This project uses the following dependencies:
|
||||
- [Fansi](https://github.com/com-lihaoyi/fansi) for colored output in the console.
|
||||
|
||||
## Linting and Formatting
|
||||
Since I wanted to learn as most as I could by making this first project, I also setup [scalafmt](https://scalameta.org/scalafmt/) for code formatting and [scalafix](https://scalacenter.github.io/scalafix/) for code linting, not that they would be particularly useful in this context.
|
||||
## License
|
||||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
||||
15
build.sbt
Normal file
15
build.sbt
Normal file
@@ -0,0 +1,15 @@
|
||||
val scala3Version = "3.7.1"
|
||||
|
||||
lazy val root = project
|
||||
.in(file("."))
|
||||
.settings(
|
||||
name := "hello-world-scala",
|
||||
version := "0.1.0-SNAPSHOT",
|
||||
scalaVersion := scala3Version,
|
||||
semanticdbEnabled := true,
|
||||
scalacOptions += "-Wunused:all",
|
||||
javaOptions += "-Dfile.encoding=UTF-8",
|
||||
javaOptions += "-Dstdout.encoding=UTF-8",
|
||||
javaOptions += "-Dstderr.encoding=UTF-8",
|
||||
libraryDependencies += "com.lihaoyi" %% "fansi" % "0.5.0"
|
||||
)
|
||||
1
project/build.properties
Normal file
1
project/build.properties
Normal file
@@ -0,0 +1 @@
|
||||
sbt.version=1.11.3
|
||||
1
project/plugins.sbt
Normal file
1
project/plugins.sbt
Normal file
@@ -0,0 +1 @@
|
||||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.3")
|
||||
6
src/main/resources/hello.txt
Normal file
6
src/main/resources/hello.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
██╗ ██╗███████╗██╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██╗ ██████╗
|
||||
██║ ██║██╔════╝██║ ██║ ██╔═══██╗ ██║ ██║██╔═══██╗██╔══██╗██║ ██╔══██╗
|
||||
███████║█████╗ ██║ ██║ ██║ ██║ ██║ █╗ ██║██║ ██║██████╔╝██║ ██║ ██║
|
||||
██╔══██║██╔══╝ ██║ ██║ ██║ ██║ ██║███╗██║██║ ██║██╔══██╗██║ ██║ ██║
|
||||
██║ ██║███████╗███████╗███████╗╚██████╔╝ ╚███╔███╔╝╚██████╔╝██║ ██║███████╗██████╔╝
|
||||
╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
|
||||
23
src/main/scala/Main.scala
Normal file
23
src/main/scala/Main.scala
Normal file
@@ -0,0 +1,23 @@
|
||||
import fansi.Attr
|
||||
import fansi.Color
|
||||
import scala.io.Source
|
||||
|
||||
def colors: List[Attr] = List(
|
||||
Color.Red,
|
||||
Color.LightRed,
|
||||
Color.Yellow,
|
||||
Color.Green,
|
||||
Color.Blue,
|
||||
Color.Magenta
|
||||
)
|
||||
|
||||
val message: String = Source.fromResource("hello.txt").mkString
|
||||
|
||||
@main def hello(): Unit = {
|
||||
val splitMessage: Array[String] = message.split("\n")
|
||||
for (i <- splitMessage.indices) {
|
||||
val colorIndex = i % colors.length
|
||||
val coloredLine = colors(colorIndex)(splitMessage(i))
|
||||
println(coloredLine)
|
||||
}
|
||||
}
|
||||
9
src/test/scala/MySuite.scala
Normal file
9
src/test/scala/MySuite.scala
Normal file
@@ -0,0 +1,9 @@
|
||||
// For more information on writing tests, see
|
||||
// https://scalameta.org/munit/docs/getting-started.html
|
||||
class MySuite extends munit.FunSuite {
|
||||
test("example test that succeeds") {
|
||||
val obtained = 42
|
||||
val expected = 42
|
||||
assertEquals(obtained, expected)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user