Package eu.svjatoslav.alyverkko_cli
Class Utils
java.lang.Object
eu.svjatoslav.alyverkko_cli.Utils
General utility functions for the Älyverkko CLI application. Currently provides ANSI color output capabilities for console messages.
Color formatting follows standard ANSI escape sequences, with specific methods for common message types like errors.
For future extensions, this class could include additional helper functions for file operations or string processing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default path for the YAML config file, typically under the user's home directory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanfileHasToComputeMarker(File file) Inspects the first line of the file to see if it starts with "TOCOMPUTE:".static FilegetConfigurationFile(eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.FileOption configFileOption) Returns the configuration file from the given option, or the default path if not present.static StringgetFirstLine(File file) Reads the first line of a file.static ConfigurationloadConfiguration(File configFile) Loads the configuration from a given file, or from the default path ifconfigFileis null.static voidprintRedMessageToConsole(String message) Prints a message in red text to the console.
-
Field Details
-
DEFAULT_CONFIG_FILE_PATH
The default path for the YAML config file, typically under the user's home directory.
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
printRedMessageToConsole
Prints a message in red text to the console.- Parameters:
message- the text to print in red.
-
getFirstLine
Reads the first line of a file.- Parameters:
file- File to read- Returns:
- First line of file or null if empty
- Throws:
IOException- if file reading fails
-
fileHasToComputeMarker
Inspects the first line of the file to see if it starts with "TOCOMPUTE:".- Parameters:
file- the file to read.- Returns:
- true if the file's first line starts with "TOCOMPUTE:".
- Throws:
IOException- if file reading fails.
-
loadConfiguration
Loads the configuration from a given file, or from the default path ifconfigFileis null.- Parameters:
configFile- the file containing the YAML config; may be null.- Returns:
- the
Configurationobject, or null if not found/invalid. - Throws:
IOException- if file I/O fails during reading.
-
getConfigurationFile
public static File getConfigurationFile(eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.FileOption configFileOption) Returns the configuration file from the given option, or the default path if not present.- Parameters:
configFileOption- the CLI option for the config file.- Returns:
- the configuration file to load.
-