Skip to content

Commit

Permalink
[1.1.0] : added support for font size flag in CLI (#15)
Browse files Browse the repository at this point in the history
* feat: added support for -size flag in CLI to adjust font size

* fix: link to license.md
  • Loading branch information
Ale1 authored Aug 5, 2023
1 parent 968b92e commit 8c7324c
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
7 changes: 7 additions & 0 deletions Packages/com.ale1.splashdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog
## com.coldtower.Splashdown

## [1.1.0]
### Added
- CLI now supports font size optional flag
### Fixed
- CLI was treating -useIcon flag as non-optional
- Link to license.md in UPM window

## [1.0.0]
### Changed
- first preview package in npm
Expand Down
39 changes: 28 additions & 11 deletions Packages/com.ale1.splashdown/Editor/Scripts/CLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,31 @@

namespace Splashdown.Editor
{
public class CLI
public static class CLI
{
//Example: /Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -projectPath ~/Desktop/Splashdown -executeMethod Splashdown.Editor.CLI.SetSplashOptions -name MySplashdown -activeSplash -l1 hello -l2 cruel -l3 world

public CLI()
{
}

/// <summary>
/// Parses command line arguments to set various options for Splashdown.
/// </summary>
/// <remarks>
/// The method takes command line arguments to find a splashdown file by name (required),
/// then toggle its use as a splash (optional),
/// toggle use as icon (optional),
/// toggle dynamic behavior (optional),
/// set three lines of text (optional),
/// and define the font size (optional).
/// If the provided name is empty, it logs an error and returns.
/// The options are updated using the provided arguments, and the asset is then reimported.
///
/// This method is intended to be called exclusively from an external command line. It is not
/// intended to be called programmatically from within the application.
/// </remarks>
/// <example>
/// An example of using this method with a command line instruction:
/// <code>
/// /Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode -projectPath ~/Desktop/Splashdown -executeMethod Splashdown.Editor.CLI.SetSplashOptions -name MySplashdown -activeSplash -l1 hello -l2 cruel -l3 world -size 23
/// </code>
/// The `-name` parameter is required. Other parameters such as `-activeSplash`, `-l1`, `-l2`, `-l3`, and `-size` are optional.
/// </example>
public static void SetSplashOptions()
{
string[] args = System.Environment.GetCommandLineArgs();
Expand All @@ -22,6 +39,7 @@ public static void SetSplashOptions()
string l1 = null;
string l2 = null;
string l3 = null;
int? size = null;

for (int i = 0; i < args.Length; i++)
{
Expand All @@ -37,9 +55,7 @@ public static void SetSplashOptions()
else if (arg == "-l1") l1 = args[i + 1];
else if (arg == "-l2") l2 = args[i + 1];
else if (arg == "-l3") l3 = args[i + 1];

//todo: add font size as CLI-compatible option
//else if (arg == "-size") fontSize = args[i + 1];
else if (arg == "-size") size = Int32.TryParse(args[i + 1], out int inputSize) ? inputSize : null;
}

if (String.IsNullOrEmpty(name))
Expand All @@ -53,6 +69,7 @@ public static void SetSplashOptions()
line1 = l1,
line2 = l2,
line3 = l3,
TargetFontSize = (SerializableInt) size
};

var guid = SplashdownUtils.GetGuidBySplashdownName(name);
Expand Down Expand Up @@ -82,7 +99,7 @@ public static void SetSplashOptions()
importer.SetActiveSplash( (bool) useSplash);
}

if (importer != null && importer.IsIconActive != useIcon)
if (useIcon != null && importer.IsIconActive != useIcon)
{
importer.SetActiveIconWithEvent( (bool) useIcon);
}
Expand Down
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Packages/com.ale1.splashdown/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# coldtower-Splashdown
# Ale1-Splashdown

See https://github.com/Ale1/Splashdown
4 changes: 2 additions & 2 deletions Packages/com.ale1.splashdown/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "com.ale1.splashdown",
"version": "1.0.0",
"version": "1.1.0",
"displayName": "Splashdown",
"description": "A unity open-source custom Splash splash and Icon generator",
"documentationUrl": "https://github.com/Ale1/Splashdown",
"changelogUrl": "CHANGELOG.MD",
"licensesUrl": "LICENCE.MD",
"licenseUrl": "LICENCE.MD",
"keywords": [
"Utils",
"Coldtower"
Expand Down

0 comments on commit 8c7324c

Please sign in to comment.