Code Monkey home page Code Monkey logo

figlet4s's Introduction

License: MIT Maven Central Tests Status Gitter chat

 _____ _       _      _   _  _
|  ___(_) __ _| | ___| |_| || |  ___
| |_  | |/ _` | |/ _ \ __| || |_/ __|
|  _| | | (_| | |  __/ |_|__   _\__ \
|_|   |_|\__, |_|\___|\__|  |_| |___/  ASCII-art banners, in Scala
         |___/

Figlet4s

Figlet4s is a library to create ASCII-art banners, in pure Scala, open source, with integrated fonts, minimal dependencies, extensive error reporting and support for effects including Cats IO. It also includes direct support for Java.

Try out Figlet4s on Scastie

Documentation

Go to https://colofabrix.github.io/figlet4s/

Changelog

You can check the changelog of Figlet4s here

What can I use Figlet4s for?

FIGlet is mainly a decorative application. But this doesn't mean it's not useful! You can use it to add some touch to your applications or environments!

Some example applications are:

License

Figlet4s is released under a "MIT" license. See LICENSE for specifics and copyright declaration.

Author Information

Fabrizio Colonna

figlet4s's People

Contributors

colofabrix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

figlet4s's Issues

Command line figlet4s

Description

As a user of the terminal I would like to use figlet4s not only as a Scala library but also from the command line.

Implementation

I would like the command line interface to be similar to the original figlet implmentation so that I don't have to learn a different way of doing the same things (this is the man page for figlet: https://linux.die.net/man/6/figlet).

I would like that terminal Figlet4s behaves like a Unix filter so I can use it as part of bigger programs.

I would like to not invoke scala directly (i.e. not using scala -cp classes figlet4s.... but I want to run it as a standard executable file. A simple way of doing this can be seen in this page: https://coderwall.com/p/ssuaxa/how-to-make-a-jar-file-linux-executable

I would like errors to be displayed nicely, when possible, instead of an uncomprehensible mess of geek lingo.

If figlet4s doesn't yet support a feature that figlet does and this feature is in the backlog, add the command line option anyway and print out a message that says the feature is not available.

Consider compiling for https://github.com/scala-native/scala-native (investigate the details of the project first)

Publish API documentation

Description

The API documentation should be published in GitHub Pages, together with the docsite.

At the moment there is a direct link to the JAR in sonatype with a hard-coded version, plus it's very slow to open and work with. Move away from this temporary solution.

Create and automated GitHub Action to build and publish the documentation at every release (check if this is possible).

Support for new effects

Description

As a user of the figlet library I would like to use the Validated applicative to handle figlet errors or, at worse, add support for my own effect.
I would like figlet to have a package that wraps results in Validated and a package that directly exposes the generic effect F[_].

Implementation

Add two new packages in the figlet4s-effects project, one for Validated and one for generic and use the existing packages as starting point to implement this feature.

On a different thought this might require a rethink of the structure of the packages because, like it is now, when importing the effects library a whole lot of unwanted dependencies can be added. I.e. if I want to use support for Either I'm forced to depend on Cats. Do not proceed before taking a decision with this.

Notes

For small, self-contained library like figlet4s I believe in the "battery included" approach and easy integration. For this reason I don't want users to fiddle with conversions to and from effects that they are not currently using in their library and this is why I want to add support for the most common and reasonable effect in the Scala ecosystem.

Evaluate and add support for Java language

Description

As a Java developer I would like to use Figlet4s in my library because there are only a few Java figlet libraries and they all lack some basic functionalities of figlet that I like.

I also don't want to worry about Java-Scala interoperability, I want to import the package of figlet4s and start using it without any "magic" or "workarounds".

Implementation

Scala code should already be interoperable with Java and there are several guides on how do to it but there are a couple of points that I'm not sure about.

Figlet4s uses heavily extension methods and I'm concerned that this can break Java compatibility. This should be tested to see if figlet4s works out of the box.

If there are issues I think the best approach would be to create a new package figlet4s-java that only Java developers will import and that tries to hide as many compatibility issues as possible.

Internal font loading fails on Windows

Configuration

OS type and version: Windows 10 21H1
JVM type and version: 11.0.13
Scala version: 2.12.13
Figlet4s version: 0.3.0

Steps

Consider the following simple test app:

import com.colofabrix.scala.figlet4s.unsafe._
import com.colofabrix.scala.figlet4s.options._

object Test extends App {

  val text = "hello, world!"
  val banner = Figlet4s.builder(text).render().asString()

  println(banner)
}

with a simple build.sbt:

name := "figlet4s-test-project"
version := "0.1"
scalaVersion := "2.12.13"
libraryDependencies += "com.colofabrix.scala" %% "figlet4s-core" % "0.3.0"

Problem

The project builds and runs fine in Linux, but crashes in Windows:

[info] done compiling
[info] running Test
[error] (run-main-0) com.colofabrix.scala.figlet4s.errors$FigletLoadingError
[error] com.colofabrix.scala.figlet4s.errors$FigletLoadingError
[error]         at com.colofabrix.scala.figlet4s.errors$FigletLoadingError$.apply(errors.scala:69)
[error]         at com.colofabrix.scala.figlet4s.core.Braket$.withResource(Braket.scala:28)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.readInternal(FontFileReader.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$2(Figlet4sClient.scala:49)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$1(Figlet4sClient.scala:48)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.loadFontInternal(Figlet4sClient.scala:47)
[error]         at com.colofabrix.scala.figlet4s.unsafe.Figlet4s$.loadFontInternal(Figlet4s.scala:36)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.$anonfun$options$1(OptionsBuilderMixin.scala:58)
[error]         at scala.Option.getOrElse(Option.scala:189)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.options(OptionsBuilderMixin.scala:58)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.render(OptionsBuilderMixin.scala:32)
[error]         at Test$.delayedEndpoint$Test$1(Test.scala:7)
[error]         at Test$delayedInit$body.apply(Test.scala:4)
[error]         at scala.Function0.apply$mcV$sp(Function0.scala:39)
[error]         at scala.Function0.apply$mcV$sp$(Function0.scala:39)
[error]         at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
[error]         at scala.App.$anonfun$main$1$adapted(App.scala:80)
[error]         at scala.collection.immutable.List.foreach(List.scala:431)
[error]         at scala.App.main(App.scala:80)
[error]         at scala.App.main$(App.scala:78)
[error]         at Test$.main(Test.scala:4)
[error]         at Test.main(Test.scala)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] Caused by: java.lang.NullPointerException
[error]         at java.base/java.io.Reader.<init>(Reader.java:167)
[error]         at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:125)
[error]         at scala.io.BufferedSource.reader(BufferedSource.scala:26)
[error]         at scala.io.BufferedSource.bufferedReader(BufferedSource.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.tapSource(FontFileReader.scala:43)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.$anonfun$readInternal$1(FontFileReader.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.Braket$.withResource(Braket.scala:24)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.readInternal(FontFileReader.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$2(Figlet4sClient.scala:49)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$1(Figlet4sClient.scala:48)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.loadFontInternal(Figlet4sClient.scala:47)
[error]         at com.colofabrix.scala.figlet4s.unsafe.Figlet4s$.loadFontInternal(Figlet4s.scala:36)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.$anonfun$options$1(OptionsBuilderMixin.scala:58)
[error]         at scala.Option.getOrElse(Option.scala:189)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.options(OptionsBuilderMixin.scala:58)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.render(OptionsBuilderMixin.scala:32)
[error]         at Test$.delayedEndpoint$Test$1(Test.scala:7)
[error]         at Test$delayedInit$body.apply(Test.scala:4)
[error]         at scala.Function0.apply$mcV$sp(Function0.scala:39)
[error]         at scala.Function0.apply$mcV$sp$(Function0.scala:39)
[error]         at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
[error]         at scala.App.$anonfun$main$1$adapted(App.scala:80)
[error]         at scala.collection.immutable.List.foreach(List.scala:431)
[error]         at scala.App.main(App.scala:80)
[error]         at scala.App.main$(App.scala:78)
[error]         at Test$.main(Test.scala:4)
[error]         at Test.main(Test.scala)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] stack trace is suppressed; run 'last Compile / bgRun' for the full output
[error] Nonzero exit code: 1
[error] (Compile / run) Nonzero exit code: 1
[error] Total time: 62 s (01:02), completed 30 Oct 2021, 0.09.15

Enforce sanity checks on PR

Description

Add sanity checks to all PRs on GitHub using Actions:

  • Tests must pass
  • Test coverage must be >= 75%
  • Scalafmt and Scalafix must pass
  • Building documentation must pass
  • Building microsite must pass

Incorrect version on microsite

Problem

The microsite is built the wrong version of the library (now it's 0.0.0) so links and package dependencies are wrong

Notes

I guess there is something wrong with GitHub Actions + sbt dynver plugin

Support for figlet control files

Description

As a user of the figlet4s library I would like to be able to use figlet control files FLC

Implementation

I have not tested much this feature in the original figlet but its definition can be found in the main standard: http://www.jave.de/figlet/figfont.html#controlfiles

Figlet4s should implement the behaviour described above and where there are doubts on the implementation it should behave as the original figlet does.

Similar features in the wild

See the figlet man page: https://linux.die.net/man/6/figlet

Add more internal fonts

Description

Figlet4s is a "battery included" library and it already ships with many internal fonts but many more are freely available online. Top up the internal fonts shipped with Figlet4s.

There are a number of places where more fonts can be found:

Figlet4s includes rendering tests for all the fonts in the library. All the new fonts must pass the test. Some of them might not for several reasons: they might be corrupt, designed badly, they might use undocumented features. Depending on the nature of the problem a case can be made to include the font in the library but skip the testing.

P.S. Pay attention to the encoding of the original font so that they are rendered the same way

Support for Justification

Description

As a user of the figlet4s library I would like to have support for justification, which is the ability to align my text left, center, or right.

Implementation

The original command line figlet allows users to align their text inside the defined max width, either left, center, right or use the default of the font.

Figlet4s already has the data structures required to support justification but doesn't implement the algorithm yet.

Similar features in the wild

See the figlet man page: https://linux.die.net/man/6/figlet

Internal font list on Windows still uses "\" path sep

Thank you so much for fixing #20. Internal font loading works correctly when using "/" path separator (i.e. "c64/platoon2"), however the internal font list still returns paths with the windows path separator (\).

Configuration

OS type and version: Windows 10 21H1
JVM type and version: 11.0.13
Scala version: 2.12.13
Figlet4s version: 0.3.1

Steps

>   println(Figlet4s.internalFonts)
Vector(1row, 3-d, 3x5, 4max, 5lineoblique, B1FF, acrobatic, alligator, alligator2, alligator3, alpha, alphabet, amc3line, amc3liv1, amcaaa01, amcneko, amcrazo2, amcrazor, amcslash, amcslder, amcthin, amctubes, amcun1, arrows, avatar, banner, banner3-D, banner3, banner4, barbwire, basic, bell, benjamin, big, bigchief, bigfig, binary, block, bolger, bright, broadway, bubble, bulbhead, c64\1943____, c64\4x4_offr, c64\64f1____, c64\a_zooloo, c64\advenger, c64\aquaplan, c64\asc_____, c64\ascii___, c64\assalt_m, c64\asslt__m, c64\atc_____, c64\atc_gran, c64\b_m__200, c64\battle_s, c64\battlesh, c64\baz__bil, c64\beer_pub, c64\bubble__, c64\bubble_b, c64\c1______, c64\c2______, c64\c_ascii_, c64\c_consen, c64\caus_in_, c64\char1___, c64\char2___, c64\char3___, c64\char4___, c64\charact1, c64\charact2, c64\charact3, c64\charact4, c64\charact5, c64\charact6, c64\characte, c64\charset_, c64\coil_cop, c64\com_sen_, c64\computer, c64\convoy__, c64\d_dragon, c64\dcs_bfmo, c64\deep_str, c64\demo_1__, c64\demo_2__, c64\demo_m__, c64\devilish, c64\druid___, c64\e__fist_, c64\ebbs_1__, c64\ebbs_2__, c64\eca_____, c64\etcrvs__, c64\f15_____, c64\faces_of, c64\fair_mea, c64\fairligh, c64\fantasy_, c64\fbr12___, c64\fbr1____, c64\fbr2____, c64\fbr_stri, c64\fbr_tilt, c64\finalass, c64\fireing_, c64\flyn_sh, c64\fp1_____, c64\fp2_____, c64\funky_dr, c64\future_1, c64\future_2, c64\future_3, c64\future_4, c64\future_5, c64\future_6, c64\future_7, c64\future_8, c64\gauntlet, c64\ghost_bo, c64\gothic, c64\gothic__, c64\grand_pr, c64\green_be, c64\hades___, c64\heavy_me, c64\heroboti, c64\high_noo, c64\hills___, c64\home_pak, c64\house_of, c64\hypa_bal, c64\hyper___, c64\inc_raw_, c64\italics_, c64\joust___, c64\kgames_i, c64\kik_star, c64\krak_out, c64\lazy_jon, c64\letter_w, c64\letterw3, c64\lexible_, c64\mad_nurs, c64\magic_ma, c64\master_o, c64\mayhem_d, c64\mcg_____, c64\mig_ally, c64\modern__, c64\new_asci, c64\nfi1____, c64\notie_ca, c64\npn_____, c64\odel_lak, c64\ok_beer_, c64\out
run__, c64\p_s_h_m_, c64\p_skateb, c64\pacos_pe, c64\panther_, c64\pawn_ins, c64\phonix__, c64\platoon2, c64\platoon_, c64\pod_____, c64\r2-d2___, c64\rad_____, c64\rad_phan, c64\radical_, c64\rainbow_, c64\rally_s2, c64\rally_sp, c64\rampage_, c64\rastan__, c64\raw_recu, c64\rci_____, c64\ripper!_, c64\road_rai, c64\rockbox_, c64\rok_____, c64\roman, c64\roman___, c64\script__, c64\skate_ro, c64\skateord, c64\skateroc, c64\sketch_s, c64\sm______, c64\space_op, c64\spc_demo, c64\star_war, c64\stealth_, c64\stencil1, c64\stencil2, c64\street_s, c64\subteran, c64\super_te, c64\t__of_ap, c64\tav1____, c64\taxi____, c64\tec1____, c64\tec_7000, c64\tecrvs__, c64\ti_pan__, c64\timesofl, c64\tomahawk, c64\top_duck, c64\trashman, c64\triad_st, c64\ts1_____, c64\tsm_____, c64\tsn_base, c64\twin_cob, c64\type_set, c64\ucf_fan_, c64\ugalympi, c64\unarmed_, c64\usa_____, c64\usa_pq__, c64\vortron_, c64\war_of_w, c64\yie-ar__, c64\yie_ar_k, c64\z-pilot_, c64\zig_zag_, c64\zone7___, calgphy2, caligraphy, catwalk, chunky, coinstak, colossal, computer, contessa, contrast, cosmic, cosmike, crawford, cricket, cyberlarge, cybermedium, cybersmall, decimal, diamond, digital, doh, doom, dosrebel, dotmatrix, double, drpepper, eftichess, eftifont, eftipiti, eftirobot, eftitalic, eftiwall, eftiwater, epic, fender, fourtops, fraktur, fuzzy, goofy, gothic, gradient, graffiti, greek, henry3d, hex, hollywood, invita, isometric1, isometric2, isometric3, isometric4, italic, ivrit, jacky, jazmine, jerusalem, katakana, kban, keyboard, larry3d, lcd, lean, letters, linux, lockergnome, madrid, marquee, maxfour, mike, mini, mirror, mnemonic, morse, moscow, nancyj-fancy, nancyj-improved, nancyj-underlined, nancyj, nipples, nscript, ntgreek, o8, octal, ogre, oldbanner, os2, pawp, peaks, peaksslant, pebbles, pepper, poison, puffy, rectangles, redphoenix, relief, relief2, reverse, roman, rot13, rounded, rowancap, rozzo, runic, s-relief, santaclara, sblood, script, serifcap, shadow, shimrod, short, slant, slide, slscript, small, smisome1, smkeyboard, smpoison, smscript, smshadow, smslant, smtengwar, speed, stacey, stampate, stampatello, standard, starwars, stellar, stop, straight, sub-zero, tanja, tengwar, term, thick, thin, threepoint, ticks, ticksslant, tiles, tinker-toy, tombstone, trek, tsalagi, tubular, twopoint, univers, usaflag, weird, whimsy)

Problem

Needless to say, using C64 fonts from the internal lists as-is fails:

  val text = "hello, world!"
  val font = Figlet4s.internalFonts.find(_.startsWith("c64")).get
  println(font)
  val banner = Figlet4s.builder(text).withInternalFont(font).render().asString()

This fails witth:

[info] running Test
c64\1943____
[error] (run-main-d) com.colofabrix.scala.figlet4s.errors$FigletLoadingError
[error] com.colofabrix.scala.figlet4s.errors$FigletLoadingError
[error]         at com.colofabrix.scala.figlet4s.errors$FigletLoadingError$.apply(errors.scala:69)
[error]         at com.colofabrix.scala.figlet4s.core.Braket$.withResource(Braket.scala:28)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.readInternal(FontFileReader.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$2(Figlet4sClient.scala:48)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$1(Figlet4sClient.scala:47)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.loadFontInternal(Figlet4sClient.scala:46)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$$anonfun$compileFonts$1.applyOrElse(OptionsBuilder.scala:245)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$$anonfun$compileFonts$1.applyOrElse(OptionsBuilder.scala:225)
[error]         at scala.PartialFunction$OrElse.apply(PartialFunction.scala:172)
[error]         at scala.Function$.$anonfun$untupled$1(Function.scala:110)
[error]         at cats.instances.ListInstances$$anon$1.step$1(list.scala:153)
[error]         at cats.instances.ListInstances$$anon$1.$anonfun$foldM$2(list.scala:158)
[error]         at cats.package$$anon$1.tailRecM(package.scala:76)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.tailRecM(package.scala:72)
[error]         at cats.instances.ListInstances$$anon$1.foldM(list.scala:158)
[error]         at cats.instances.ListInstances$$anon$1.foldM(list.scala:17)
[error]         at cats.Foldable$Ops.foldM(Foldable.scala:975)
[error]         at cats.Foldable$Ops.foldM$(Foldable.scala:974)
[error]         at cats.Foldable$ToFoldableOps$$anon$6.foldM(Foldable.scala:1008)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$.compile(OptionsBuilder.scala:206)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder.compile(OptionsBuilder.scala:163)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.buildOptions$lzycompute(OptionsBuilderMixin.scala:15)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.buildOptions(OptionsBuilderMixin.scala:15)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.render(OptionsBuilderMixin.scala:32)
[error]         at Test$.delayedEndpoint$Test$1(Test.scala:27)
[error]         at Test$delayedInit$body.apply(Test.scala:8)
[error]         at scala.Function0.apply$mcV$sp(Function0.scala:39)
[error]         at scala.Function0.apply$mcV$sp$(Function0.scala:39)
[error]         at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
[error]         at scala.App.$anonfun$main$1$adapted(App.scala:80)
[error]         at scala.collection.immutable.List.foreach(List.scala:431)
[error]         at scala.App.main(App.scala:80)
[error]         at scala.App.main$(App.scala:78)
[error]         at Test$.main(Test.scala:8)
[error]         at Test.main(Test.scala)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] Caused by: java.lang.NullPointerException
[error]         at java.base/java.io.Reader.<init>(Reader.java:167)
[error]         at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:125)
[error]         at scala.io.BufferedSource.reader(BufferedSource.scala:26)
[error]         at scala.io.BufferedSource.bufferedReader(BufferedSource.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.tapSource(FontFileReader.scala:43)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.$anonfun$readInternal$1(FontFileReader.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.Braket$.withResource(Braket.scala:24)
[error]         at com.colofabrix.scala.figlet4s.core.FontFileReader$.readInternal(FontFileReader.scala:27)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$2(Figlet4sClient.scala:48)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.$anonfun$loadFontInternal$1(Figlet4sClient.scala:47)
[error]         at cats.package$$anon$1.flatMap(package.scala:73)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.flatMap(package.scala:69)
[error]         at cats.FlatMap$Ops.flatMap(FlatMap.scala:229)
[error]         at cats.FlatMap$Ops.flatMap$(FlatMap.scala:229)
[error]         at cats.FlatMap$ToFlatMapOps$$anon$2.flatMap(FlatMap.scala:243)
[error]         at com.colofabrix.scala.figlet4s.core.Figlet4sClient$.loadFontInternal(Figlet4sClient.scala:46)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$$anonfun$compileFonts$1.applyOrElse(OptionsBuilder.scala:245)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$$anonfun$compileFonts$1.applyOrElse(OptionsBuilder.scala:225)
[error]         at scala.PartialFunction$OrElse.apply(PartialFunction.scala:172)
[error]         at scala.Function$.$anonfun$untupled$1(Function.scala:110)
[error]         at cats.instances.ListInstances$$anon$1.step$1(list.scala:153)
[error]         at cats.instances.ListInstances$$anon$1.$anonfun$foldM$2(list.scala:158)
[error]         at cats.package$$anon$1.tailRecM(package.scala:76)
[error]         at com.colofabrix.scala.figlet4s.unsafe.package$$anon$1.tailRecM(package.scala:72)
[error]         at cats.instances.ListInstances$$anon$1.foldM(list.scala:158)
[error]         at cats.instances.ListInstances$$anon$1.foldM(list.scala:17)
[error]         at cats.Foldable$Ops.foldM(Foldable.scala:975)
[error]         at cats.Foldable$Ops.foldM$(Foldable.scala:974)
[error]         at cats.Foldable$ToFoldableOps$$anon$6.foldM(Foldable.scala:1008)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder$.compile(OptionsBuilder.scala:206)
[error]         at com.colofabrix.scala.figlet4s.options.OptionsBuilder.compile(OptionsBuilder.scala:163)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.buildOptions$lzycompute(OptionsBuilderMixin.scala:15)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.buildOptions(OptionsBuilderMixin.scala:15)
[error]         at com.colofabrix.scala.figlet4s.unsafe.OptionsBuilderMixin$OptionsBuilderOps.render(OptionsBuilderMixin.scala:32)
[error]         at Test$.delayedEndpoint$Test$1(Test.scala:27)
[error]         at Test$delayedInit$body.apply(Test.scala:8)
[error]         at scala.Function0.apply$mcV$sp(Function0.scala:39)
[error]         at scala.Function0.apply$mcV$sp$(Function0.scala:39)
[error]         at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
[error]         at scala.App.$anonfun$main$1$adapted(App.scala:80)
[error]         at scala.collection.immutable.List.foreach(List.scala:431)
[error]         at scala.App.main(App.scala:80)
[error]         at scala.App.main$(App.scala:78)
[error]         at Test$.main(Test.scala:8)
[error]         at Test.main(Test.scala)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)

Notes

As I wrote in #20, resources always use / path separator, regardless of the OS path separators, thus treating resource paths as Path object is little erroneous. At the very list you'll want to do something like this in the end: .replaceAll(File.pathSeparator, "/").

Add sbt-tpolecat

Description

Remove the manual managemnt of compiler flags and use sbt-tpolecat.
This will also help in migrating to Scala 3

Support for vertical alignment

Description

As a user of the figlet4s library I would like to use different types of vertical layouts as the original figlet does.

Implementation

When wrapping lines figlet can align the next line in different way in a similar way as he places one character after the other. Support the same layout as the original figlet command line does.

The core algorithm should suffice, however, at the moment, is specialized for left-to-right horizontal appending of characters.

Similar features in the wild

See the figlet man page: https://linux.die.net/man/6/figlet

Investigate and possibly add support for Scala 3

Description

Scala is clearly moving towards the next version and Figlet4s wants to be an up to date library.

Do a spike for to investigate the effort required to support Scala 3 and produce a PoC. Consider using 2.13 libraries for Scala 3 too.

If the PoC is succesfully and the effort required it not too big (i.e. a week for production ready), extend the PoC to full feature.

Figlet4s needs to also support Scala 2.12 and 2.13 at the moment of writing

Status of the libraries as of 22/10/2021

Core libraries

  • cats-core: supports Scala 3
  • cats-effects: supports Scala 3
  • enumeratum: does not support Scala 3 but not needed in Scala 3

Testing

  • scalatest: supports Scala 3
  • scalacheck: found a mention of Scala 3
  • scalamock / mockito: do not support Scala 3, consider dropping it
  • scalameter: does not support Scala 3, consider dropping it

SBT plugins

  • scalafmt: supports Scala 3
  • scalafix: limited support for Scala 3
  • wartremover: supports Scala 3

Compiler

  • compiler options: sbt-tpolecat provides some useful compiler flags
  • linting: there seems to be very limited compiler linting

Create and publish docsite

Description

Create and publish a docsite for the project to be hosted in GitHub Pages.

The final result has to:

  • include usage of all the main features of the library
  • be minimal in the sense that it has to include clear and concise examples of the most common cases
  • not include a detailed explanation of all the feature (reference the javadoc for API and options)

I saw there are several ways this can be done with sbt plugins in different formats. I generally like the stile of docsites like Cats and Circe. Find out what technology they use and apply the same.

Create an automated GitHub Action to build and publish the docsite at every release (check if this is possible).

Support for Print Direction

Description

As a user of the figlet4s library I would like to have support for print direction, which is the ability to print the text left-to-right (as per usual western writing) or right-to-left.

Here are the example of what that means.
Left-to-right:

    _    _      ____    _
   / \  | |__  / ___|__| |
  / _ \ | '_ \| |   / _` |
 / ___ \| |_) | |__| (_| |
/_/   \_\_.__/ \____\__,_|

Right-to-left:

                          _  ____ _       _
                       __| |/ ___| |__   / \
                      / _` | |   | '_ \ / _ \
                     | (_| | |___| |_) / ___ \
                      \__,_|\____|_.__/_/   \_\

Implementation

The original command line figlet allows users to print their text left-to-right, right-to-left or use the default setting for the font.

Figlet4s already has the data structures required to support print direction but doesn't implement the algorithm yet.

Similar features in the wild

See the figlet man page: https://linux.die.net/man/6/figlet

Support for zipped fonts

Description

As a user of the figlet4s library I would like to be able to load FLF fonts that have been saved as zip files

Implementation

Figlet font files can be either normal text files or zipped text files and this different is reflected in their content rather than the file name (i.e. a zipped font still has extension .flf). Figlet4s needs to be able to distinguish normal and zipped text files using only the content of the file itself.

Similar features in the wild

See the figlet man page: https://linux.die.net/man/6/figlet

Automate build, test and publish

Description

Using GitHub Actions, create an automated release system that:

  • Tests and build the library at every commit
  • Publishes it to the Sonatype snapshot repository when there is a new tag

I found this can be done in a variety of way but I haven't settled yet on the best/easier:

  • sbt-github-actions: This seems a good options, investigate more if it fits my needs
  • sbt-release: This moves most of the process on SBT and I think it shouldn't be SBT's responsibility plus SBT is quite complicated so I'd like to stay away from it* Manual writing of GitHub Actions
  • sbt-traviscs (yes, consider also not using GitHub Actions): TravisCI is a well established tool and maybe it can be better than the above. Investigate.

Improve test coverage

Description

Currently many parts of the code are not tested, specifically font loading checks but other things too.

Using scoverage look what's missing and add tests for the most important parts (i.e. test that a constraint is respected but don't teste that a println function works).

This can also mean removing unused code (scoverage can report unused code) if it really not needed, not even for a future release.

Upgrade Scalafix and Scala 2.13 and 2.12

Description

Upgrade Scalafix to the latest version for the supported Scala versions.

When doing it the first time, I ran into several issues where the semanticdb is not loaded (I noticed it happens to test files only but I didn't double check it). This issue starts with Scalafix 0.9.28.

Keeping Scalafix to 0.9.28 prevents from upgrading Scala to the latest 2.13 and 2.12 versions. So, when Scalafix is fixed, upgrade also Scala.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.