-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add CLI commands for assigning texture and audio groups and their
smoke tests.
- Loading branch information
1 parent
8462709
commit 6350afa
Showing
7 changed files
with
148 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env node | ||
import commander, { CommanderStatic } from "commander"; | ||
import { oneline, undent } from "../lib/strings"; | ||
import {assignAudioGroups, AssignCliOptions} from './lib/assign'; | ||
|
||
const cli = commander; | ||
|
||
cli.description(undent` | ||
Assign all audios in a GMS IDE folder to a group.`) | ||
.requiredOption("--folder <folder>", undent` | ||
This is the folder name shown in the GMS IDE, not the folder name of the actual audio file. | ||
For example, a audio called "snd_title" is shown in the "Sounds" folder in the IDE, whereas | ||
the actual audio file might be at "project/sounds/snd_title/snd_title.yy". | ||
`) | ||
.requiredOption("--group-name <name>", oneline` | ||
The name of the audio group. If it does not exist, it will be created. | ||
`) | ||
.option("--target-project-path <path>", oneline` | ||
Path to the target Gamemaker Studio 2 project. If not set, will use the current directory. | ||
`) | ||
.parse(process.argv); | ||
|
||
assignAudioGroups(cli as AssignCliOptions & CommanderStatic); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env node | ||
import commander, { CommanderStatic } from "commander"; | ||
import { oneline, undent } from "../lib/strings"; | ||
import {assignTextureGroups, AssignCliOptions} from './lib/assign'; | ||
|
||
const cli = commander; | ||
|
||
cli.description(undent` | ||
Assign all sprites in a GMS IDE folder to a group.`) | ||
.requiredOption("--folder <folder>", undent` | ||
This is the folder name shown in the GMS IDE, not the folder name of the actual sprite file. | ||
For example, a sprite called "sp_title" is shown in the "Sprites" folder in the IDE, whereas | ||
the actual sprite file might be at "project/sprites/sp_title/sp_title.yy". | ||
`) | ||
.requiredOption("--group-name <name>", oneline` | ||
The name of the texture group. If it does not exist, it will be created. | ||
`) | ||
.option("--target-project-path <path>", oneline` | ||
Path to the target Gamemaker Studio 2 project. If not set, will use the current directory. | ||
`) | ||
.parse(process.argv); | ||
|
||
assignTextureGroups(cli as AssignCliOptions & CommanderStatic); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env node | ||
import commander from "commander"; | ||
const cli = commander; | ||
|
||
cli.description("Modify resource group assignments in Gamemaker Studio 2 projects.") | ||
.command("texture-groups", "Modify texture group assignments.") | ||
.command("audio-groups", "Modify audio group assignments.") | ||
.parse(process.argv); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import cli_assert from './cli-assert'; | ||
import { Gms2Project } from '../../lib/Gms2Project'; | ||
|
||
export type AssignCliOptions = { | ||
folder: string, | ||
groupName: string, | ||
targetProjectPath?: string | ||
} | ||
|
||
function normalizeAssignOptions(options: AssignCliOptions){ | ||
let {targetProjectPath} = options; | ||
if (targetProjectPath){ | ||
cli_assert.assertPathExists(targetProjectPath); | ||
} | ||
else{ | ||
targetProjectPath = process.cwd(); | ||
} | ||
|
||
return { | ||
folder: options.folder, | ||
groupName: options.groupName, | ||
targetProjectPath | ||
}; | ||
} | ||
|
||
export function assignTextureGroups (options: AssignCliOptions){ | ||
options = normalizeAssignOptions(options); | ||
const targetProject = new Gms2Project(options.targetProjectPath); | ||
targetProject.addTextureGroupAssignment(options.folder, options.groupName); | ||
} | ||
|
||
export function assignAudioGroups (options: AssignCliOptions){ | ||
options = normalizeAssignOptions(options); | ||
const targetProject = new Gms2Project(options.targetProjectPath); | ||
targetProject.addAudioGroupAssignment(options.folder, options.groupName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters