Skip to content

Commit

Permalink
Rename commands: remove - prefix for action commands and set -- p…
Browse files Browse the repository at this point in the history
…refix for settings commands
  • Loading branch information
iamgio committed Jan 29, 2024
1 parent 14630e1 commit da36e23
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
rm -rf */target/*-without-dependencies.jar
cp */target/*.jar staging
mv staging/*lib.jar staging/libraries
- name: Run -welcome
- name: Run welcome command
run: |
cd staging
java -jar pikt.jar -welcome
java -jar pikt.jar welcome
- name: Get output files
run: ls -d "$PWD/staging/"*
- name: Publish JAR
Expand Down
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,25 @@ If not specified, points by default to `./libraries/stdlib.jar`;

The following arguments enable settings that affect Pikt's behavior.

- `-interpret` runs the generated code via the JVM compiler;
- `--interpret` runs the generated code via the JVM compiler;


- `-printoutput` displays the generated Kotlin code;
- `--printoutput` displays the generated Kotlin code;


- `-nocompile` prevents the generation of any executable file;
- `--nocompile` prevents the generation of any executable file;


- `-pixelinfo` adds information about pixel coordinates to the output code as comments;
- `--pixelinfo` adds information about pixel coordinates to the output code as comments;


- `-imgoutput=path` sets the output file for image-generating commands (see below). If not specified, defaults to the source image path followed by a suffix;
- `--imgoutput=path` sets the output file for image-generating commands (see below). If not specified, defaults to the source image path followed by a suffix;


- `-chainoutput` enables output chaining for image-generating commands: the output of a command becomes the input for the next one. It requires `-imgoutput` to be set.
- `--chainoutput` enables output chaining for image-generating commands: the output of a command becomes the input for the next one. It requires `-imgoutput` to be set.


- `-pl[=type]` sets the active pixel logger type.
- `--pl[=type]` sets the active pixel logger type.
A pixel logger is responsible for printing pixels on screen,
for example in case of compile-time errors.
Available types: `none`, `16`, `256`, `rgb`, `box`.
Expand Down Expand Up @@ -171,57 +171,57 @@ The following arguments enable settings that affect Pikt's behavior.
The following arguments execute tasks and exit when completed.
These are handy shortcuts that replace several manual actions, such as image transformations, while being unrelated to code generation and compilation.

- `-downloadcompiler=type[,version]` downloads the zipped Kotlin compiler for the given platform (`jvm`, `windows`, `macos`, `linux`).
- `downloadcompiler=type[,version]` downloads the zipped Kotlin compiler for the given platform (`jvm`, `windows`, `macos`, `linux`).
`version` defaults to `1.9.21`.


- `-createscheme` creates a new [color scheme](core/src/main/resources/colors.properties) with default values.
- `createscheme` creates a new [color scheme](core/src/main/resources/colors.properties) with default values.
It automatically appends library colors too, e.g. the [stdlib scheme](stdlib/src/main/resources/colors.properties), loaded from `-Dlib`;


- `-exportscheme` generates a useful color palette image out of the given color scheme;
- `exportscheme` generates a useful color palette image out of the given color scheme;


- `-recolorize[=method]` creates a copy of the source image (that relies on the default scheme) and adapts it to a custom scheme (specified by `-Dcolors`).
- `recolorize[=method]` creates a copy of the source image (that relies on the default scheme) and adapts it to a custom scheme (specified by `-Dcolors`).
`method` defines the way properties with more than one color are handled; it can be either `first` (default), `last` or `random`;


- `-standardize` creates a copy of the source image (that relies on a custom scheme) and adapts it to the default scheme;
- `standardize` creates a copy of the source image (that relies on a custom scheme) and adapts it to the default scheme;


- `-compact[=size]` creates a compacted copy of the source image with no whitespaces between pixels.
- `compact[=size]` creates a compacted copy of the source image with no whitespaces between pixels.
If `size` is not specified, it will try to create a square-ish image.
`size` can be defined via `w?h?`, where both `w`and `h` are optional (in case one is missing, it will be calculated the same way as before) (e.g. `w10h5`, `w10`, `h5`);


- `-decompact` creates a decompacted copy of the source image with one statement per line;
- `decompact` creates a decompacted copy of the source image with one statement per line;


- `-standardecompact` runs `-standardize` + `-decompact`;
- `standardecompact` runs `standardize` + `decompact`;


- `-colorswap=<swaps>` swaps colors from the source image.
- `colorswap=<swaps>` swaps colors from the source image.
`swaps` is defined as `from1:to1,from2:to2,...` where `from` and `to` are hexadecimal colors;


- `-mask=path` creates a masked copy of the source image, loading the mask image from `path`;
- `mask=path` creates a masked copy of the source image, loading the mask image from `path`;


- `-strconvert[=string]` converts a string into a sequence of RGB (grayscale) values supported by Pikt and prints them out.
- `strconvert[=string]` converts a string into a sequence of RGB (grayscale) values supported by Pikt and prints them out.
If `string` is not specified, input is read from stdin.
_See [Hello world!](https://github.com/iAmGio/pikt/wiki/Hello-world) for further information._
For instance, `-strconvert="Hello Pikt!"` prints:
For instance, `strconvert="Hello Pikt!"` prints:

```
RGB: 72 101 108 108 111 32 80 105 107 116 33
H e l l o P i k t !
```

- `-welcome` runs `-createscheme`, `-exportscheme` (both on `colors`), `-downloadcompiler=jvm` and creates a ready-to-use Hello World source.
- `welcome` runs `createscheme`, `exportscheme` (both on `colors`), `downloadcompiler=jvm` and creates a ready-to-use Hello World source.
Its output is already zipped in the downloadable archive;


- `-help` shows these commands.
- `help` shows these commands.


More in-depth information about image transformation commands can be found [here](https://github.com/iAmGio/pikt/wiki/Image-transformation-commands).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import java.io.FileOutputStream
import java.io.IOException

/**
* Triggered by -createscheme argument
* Triggered by the `createscheme` argument
*
* @author Giorgio Garofalo
*/
class CreateSchemeCommand : Command("-createscheme", closeOnComplete = true) {
class CreateSchemeCommand : Command("createscheme", closeOnComplete = true) {
override fun execute(args: String?) {
val retriever = PiktPropertiesRetriever()
val libraries = retriever.libraries()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import eu.iamgio.pikt.util.KotlinCompilerDownloader
import eu.iamgio.pikt.util.KotlinCompilerType

/**
* Triggered by -downloadcompiler=type[,version] argument
* Triggered by `downloadcompiler=type[,version]` argument
*
* @author Giorgio Garofalo
*/
class DownloadCompilerCommand : Command("-downloadcompiler", closeOnComplete = true) {
class DownloadCompilerCommand : Command("downloadcompiler", closeOnComplete = true) {
override fun execute(args: String?) {
val type: KotlinCompilerType?
val version: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import java.io.FileInputStream
import java.io.IOException

/**
* Triggered by -exportscheme argument.
* Triggered by the `exportscheme` argument.
* Creates a color palette.
*
* @author Giorgio Garofalo
*/
class ExportSchemeCommand : Command("-exportscheme", closeOnComplete = true) {
class ExportSchemeCommand : Command("exportscheme", closeOnComplete = true) {
override fun execute(args: String?) {
val schemeFile = PiktPropertiesRetriever().colorsFile()
?: exit(ERROR_BAD_PROPERTIES, message = "Color scheme (-Dcolors) not set.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import eu.iamgio.pikt.log.Log
private const val HELP_PATH = "/help.yml"

/**
* Triggered by the -help argument.
* Triggered by the `help` argument.
* Shows command and property information.
*
* @author Giorgio Garofalo
*/
class HelpCommand : Command("-help", closeOnComplete = true) {
class HelpCommand : Command("help", closeOnComplete = true) {

/**
* Formats some [text] as a title.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import eu.iamgio.pikt.log.pixel.AsciiBoxConsolePixelLogger
import eu.iamgio.pikt.log.pixel.RGBConsolePixelLogger

/**
* Triggered by the -pl=type argument.
* Triggered by the `--pl[=type]` argument.
* Defines the logger used to log pixels, for example in case of errors.
*
* @see Log.pixelLogger
* @author Giorgio Garofalo
*/
class PixelLoggerCommand : Command("-pl", isSettingsCommand = true) {
class PixelLoggerCommand : Command("--pl", isSettingsCommand = true) {

override fun execute(args: String?) {
Log.pixelLogger = when(args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import eu.iamgio.pikt.GlobalSettings
import eu.iamgio.pikt.command.Command

/**
* A no-arguments command that enables a given property.
* A zero-arguments command that enables a given property.
* @author Giorgio Garofalo
*/
open class SettingsCommand(name: String) : Command(name, isSettingsCommand = true) {
Expand All @@ -17,22 +17,22 @@ open class SettingsCommand(name: String) : Command(name, isSettingsCommand = tru
* Runs the generated code via the JVM compiler.
*/
class InterpretCommand : SettingsCommand(CMD_INTERPRET)
const val CMD_INTERPRET = "-interpret"
const val CMD_INTERPRET = "--interpret"

/**
* Prints the output code to console.
*/
class PrintOutputCommand : SettingsCommand(CMD_PRINTOUTPUT)
const val CMD_PRINTOUTPUT = "-printoutput"
const val CMD_PRINTOUTPUT = "--printoutput"

/**
* Adds pixel coordinates to the output code.
*/
class PixelInfoCommand : SettingsCommand(CMD_PIXELINFO)
const val CMD_PIXELINFO = "-pixelinfo"
const val CMD_PIXELINFO = "--pixelinfo"

/**
* Lets Pikt run and generate code without actually compiling it into an executable.
*/
class NoCompileCommand : SettingsCommand(CMD_NOCOMPILE)
const val CMD_NOCOMPILE = "-nocompile"
const val CMD_NOCOMPILE = "--nocompile"
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import eu.iamgio.pikt.log.Log
import eu.iamgio.pikt.log.pixel.ConsolePixelLogger

/**
* Triggered by -strconvert=string argument.
* Triggered by the `strconvert[=string]` argument.
* Converts a string into a sequence of RGB values supported by Pikt and prints them out.
*
* @author Giorgio Garofalo
*/
class StringConvertCommand : Command("-strconvert", closeOnComplete = true) {
class StringConvertCommand : Command("strconvert", closeOnComplete = true) {
override fun execute(args: String?) {
if(args == null) {
// Read lines from stdin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import java.io.FileOutputStream
private const val HELLO_WORLD = "helloworld.png"

/**
* Triggered by -welcome argument. Creates useful initial files for the first run.
* Triggered by `welcome` argument. Creates useful initial files for the first run.
* It is also called by the GitHub action before zipping.
*
* @author Giorgio Garofalo
*/
class WelcomeCommand : Command("-welcome", closeOnComplete = true) {
class WelcomeCommand : Command("welcome", closeOnComplete = true) {
override fun execute(args: String?) {
Log.info("-----\nWelcome to Pikt!\n-----\n")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package eu.iamgio.pikt.command.commands.imageprocessing
import eu.iamgio.pikt.command.Command

/**
* Triggered by -chainoutput argument.
* Triggered by the `--chainoutput` argument.
* Allows chaining between image transformation commands: the output of an image processing command becomes the input for the next command.
* It is recommended to use in combination with [ImageOutputCommand].
*
* @see ImageProcessingUtils.enableChaining
* @author Giorgio Garofalo
*/
class ChainOutputCommand : Command("-chainoutput", isSettingsCommand = true) {
class ChainOutputCommand : Command("--chainoutput", isSettingsCommand = true) {
override fun execute(args: String?) {
ImageProcessingUtils.enableChaining = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import eu.iamgio.pikt.log.Log
import eu.iamgio.pikt.properties.PiktPropertiesRetriever

/**
* Triggered by -colorswap=<swaps> argument,
* Triggered by the `colorswap=<swaps>` argument,
* where `<swaps>` is a list of `from:to` separated by a comma.
*
* Example: `-swapcolors=FF0000:FFFF00,00FF00:0000FF`
*
* @author Giorgio Garofalo
*/
class ColorSwapCommand : Command("-colorswap", closeOnComplete = true) {
class ColorSwapCommand : Command("colorswap", closeOnComplete = true) {
override fun execute(args: String?) {
if(args == null) {
Log.error("Usage: -colorswap=<from1:to1,from2,to2,...>. Exiting.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import eu.iamgio.pikt.log.Log
import eu.iamgio.pikt.properties.PiktPropertiesRetriever

/**
* Triggered by -compact[=size] argument.
* Triggered by the `-compact[=size]` argument.
*
* @author Giorgio Garofalo
*/
class CompactCommand : Command("-compact", closeOnComplete = true) {
class CompactCommand : Command("compact", closeOnComplete = true) {
override fun execute(args: String?) {
val properties = PiktPropertiesRetriever().retrieve()
val piktImage = PiktImage(properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import eu.iamgio.pikt.log.Log
import eu.iamgio.pikt.properties.PiktPropertiesRetriever

/**
* Triggered by -decompact argument.
* Triggered by the `-decompact` argument.
*
* @author Giorgio Garofalo
*/
class DecompactCommand : Command("-decompact", closeOnComplete = true) {
class DecompactCommand : Command("decompact", closeOnComplete = true) {
override fun execute(args: String?) {
val properties = PiktPropertiesRetriever().retrieve()
val piktImage = PiktImage(properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import eu.iamgio.pikt.log.Log
import java.io.File

/**
* Triggered by -imgoutput=path argument.
* Triggered by the `--imgoutput=path` argument.
* Defines the output file name for the operations in this file.
*
* @see ImageProcessingUtils.output
* @author Giorgio Garofalo
*/
class ImageOutputCommand : Command("-imgoutput", isSettingsCommand = true) {
class ImageOutputCommand : Command("--imgoutput", isSettingsCommand = true) {
override fun execute(args: String?) {
if(args == null) {
Log.warn("Expected -imgoutput=<path>. Using default path.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import java.io.File


/**
* Triggered by -mask=<path> argument.
* Triggered by the `mask=<path>` argument.
*
* @author Giorgio Garofalo
*/
class MaskCommand : Command("-mask", closeOnComplete = true) {
class MaskCommand : Command("mask", closeOnComplete = true) {
override fun execute(args: String?) {
if(args == null) {
Log.error("Expected -mask=<mask path>. Exiting.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import eu.iamgio.pikt.log.Log
import eu.iamgio.pikt.properties.PiktPropertiesRetriever

/**
* Triggered by -recolorize[=method] argument.
* Triggered by the `recolorize[=method]` argument.
*
* @author Giorgio Garofalo
*/
class RecolorizeCommand : Command("-recolorize", closeOnComplete = true) {
class RecolorizeCommand : Command("recolorize", closeOnComplete = true) {
override fun execute(args: String?) {
val properties = PiktPropertiesRetriever().retrieve()
val sourceImage = ImageProcessingUtils.read(properties.source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import eu.iamgio.pikt.log.Log
import eu.iamgio.pikt.properties.PiktPropertiesRetriever

/**
* Triggered by -standardize argument.
* Triggered by the `standardize` argument.
*
* @author Giorgio Garofalo
*/
class StandardizeCommand : Command("-standardize", closeOnComplete = true) {
class StandardizeCommand : Command("standardize", closeOnComplete = true) {
override fun execute(args: String?) {
val properties = PiktPropertiesRetriever().retrieve()
val sourceImage = ImageProcessingUtils.read(properties.source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import eu.iamgio.pikt.log.Log
import eu.iamgio.pikt.properties.PiktPropertiesRetriever

/**
* Triggered by -standardecompact argument.
* Triggered by the `standardecompact` argument.
*
* -standardize + -decompact
*
* @author Giorgio Garofalo
*/
class StandardizeDecompactCommand : Command("-standardecompact", closeOnComplete = true) {
class StandardizeDecompactCommand : Command("standardecompact", closeOnComplete = true) {
override fun execute(args: String?) {
val properties = PiktPropertiesRetriever().retrieve()
val piktImage = PiktImage(properties)
Expand Down
Loading

0 comments on commit da36e23

Please sign in to comment.