First commit

This commit is contained in:
2025-07-25 10:17:27 +02:00
commit be2d24771e
11 changed files with 129 additions and 0 deletions

32
.gitignore vendored Normal file
View 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
View File

@@ -0,0 +1,11 @@
rules = [
RemoveUnused,
DisableSyntax,
LeakingImplicitClassVal,
NoValInForComprehension,
ProcedureSyntax,
RedundantSyntax,
OrganizeImports,
NoAutoTupling,
ExplicitResultTypes
]

5
.scalafmt.conf Normal file
View File

@@ -0,0 +1,5 @@
version = 3.9.8
runner.dialect = scala3
align.preset = more
maxColumn = 120

26
README.md Normal file
View 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.
![](img.png)
## 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
View 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"
)

BIN
img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

1
project/build.properties Normal file
View File

@@ -0,0 +1 @@
sbt.version=1.11.3

1
project/plugins.sbt Normal file
View File

@@ -0,0 +1 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.3")

View File

@@ -0,0 +1,6 @@
██╗ ██╗███████╗██╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██╗ ██████╗
██║ ██║██╔════╝██║ ██║ ██╔═══██╗ ██║ ██║██╔═══██╗██╔══██╗██║ ██╔══██╗
███████║█████╗ ██║ ██║ ██║ ██║ ██║ █╗ ██║██║ ██║██████╔╝██║ ██║ ██║
██╔══██║██╔══╝ ██║ ██║ ██║ ██║ ██║███╗██║██║ ██║██╔══██╗██║ ██║ ██║
██║ ██║███████╗███████╗███████╗╚██████╔╝ ╚███╔███╔╝╚██████╔╝██║ ██║███████╗██████╔╝
╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝

23
src/main/scala/Main.scala Normal file
View 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)
}
}

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