Skip to content

Commit daf7754

Browse files
feat: improve help
1 parent e28a5ae commit daf7754

File tree

10 files changed

+36
-13
lines changed

10 files changed

+36
-13
lines changed

Sources/Tests/InputPathTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ struct InputPathTests {
3333
#expect(path.lastComponent == "file.swift")
3434
}
3535

36+
@Test
37+
func inputPath_firstRelativeComponent_shouldReturnCorrectValue() {
38+
let path = InputPath(filePath, projectRoot: projectRoot)
39+
40+
#expect(path.firstRelativeComponent == "Group1")
41+
}
42+
3643
@Test
3744
func inputPath_equals_shouldReturnTrue() {
3845
let path1 = InputPath(filePath, projectRoot: projectRoot)

Sources/Tests/MoveGroupCommandTests.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension SerializedSuite {
1111
// ---------------------------------------------------------------------------------------
1212
extension SerializedSuite.MoveGroupCommandTests {
1313
@Test
14-
func moveGroup_shouldMoveGroupInProjectAndOnDisk() throws {
14+
func moveGroup_shouldMoveGroupInProjectAndOnDisk_andShouldNotChangeTarget() throws {
1515
let group = Files.Helpers.GeneralUtils.Subfolder2.group
1616
let dest = Files.XcodebuildNvimApp.Modules.group
1717
let newGroupPath = "\(dest)/Subfolder2"
@@ -28,6 +28,10 @@ extension SerializedSuite.MoveGroupCommandTests {
2828

2929
try notExpectGroupInProject(group.asInputPath)
3030
try expectGroupInProject(newGroupPath.asInputPath)
31+
try expectTargets(
32+
["Helpers", "XcodebuildNvimApp"],
33+
forFile: newGroupPath.asInputPath.appending("String+Extensions.swift")
34+
)
3135
try validateProject()
3236
}
3337

Sources/XcodeProjectCLI/Core/ProjectTargets.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ final class ProjectTargets {
6363
}
6464
}
6565

66-
let firstGroup = groupPath.relativePathComponents.first ?? ""
66+
let firstGroup = groupPath.firstRelativeComponent
6767
return project.pbxproj.targets(named: firstGroup)
6868
}
6969

Sources/XcodeProjectCLI/Models/InputPath.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ extension InputPath {
5757
extension InputPath {
5858
var isRelative: Bool { !path.hasPrefix("/") }
5959

60+
var firstRelativeComponent: String { relativePathComponents.first ?? "" }
61+
6062
var lastComponent: String { nsString.lastPathComponent }
6163

6264
var exists: Bool { FileManager.default.fileExists(atPath: absolutePath) }

Sources/XcodeProjectCLI/Subcommands/Files/AddFileCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct AddFileCommand: ParsableCommand {
99
@OptionGroup
1010
var options: ProjectWriteOptions
1111

12-
@Option(name: .customLong("file"), help: "Path to file.")
12+
@Option(name: .customLong("file"), help: .init("File path.", valueName: "file-path"))
1313
var filePath: String
1414

1515
@Option(help: "Comma separated list of target names.")

Sources/XcodeProjectCLI/Subcommands/Files/DeleteFileCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct DeleteFileCommand: ParsableCommand {
1010
@OptionGroup
1111
var options: ProjectWriteOptions
1212

13-
@Option(name: .customLong("file"), help: "Path to file.")
13+
@Option(name: .customLong("file"), help: .init("File path.", valueName: "file-path"))
1414
var filePath: String
1515

1616
func run() throws {

Sources/XcodeProjectCLI/Subcommands/Files/RenameFileCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct RenameFileCommand: ParsableCommand {
1010
@OptionGroup
1111
var options: ProjectWriteOptions
1212

13-
@Option(name: .customLong("file"), help: "Path to file.")
13+
@Option(name: .customLong("file"), help: .init("File path.", valueName: "file-path"))
1414
var filePath: String
1515

1616
@Option(name: .customLong("name"), help: "New name for the file.")

Sources/XcodeProjectCLI/Subcommands/Groups/AddGroupCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct AddGroupCommand: ParsableCommand {
1010
@OptionGroup
1111
var options: ProjectWriteOptions
1212

13-
@Option(name: .customLong("group"), help: "Path to group.")
13+
@Option(name: .customLong("group"), help: .init("Group path.", valueName: "group-path"))
1414
var groupPath: String
1515

1616
@Flag(help: "If set, the tool will create missing groups in the project structure.")

Sources/XcodeProjectCLI/Subcommands/Groups/DeleteGroupCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct DeleteGroupCommand: ParsableCommand {
1010
@OptionGroup
1111
var options: ProjectWriteOptions
1212

13-
@Option(name: .customLong("group"), help: "Path to group.")
13+
@Option(name: .customLong("group"), help: .init("Group path.", valueName: "group-path"))
1414
var groupPath: String
1515

1616
func run() throws {

Sources/XcodeProjectCLI/Subcommands/Groups/MoveGroupCommand.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,29 @@ struct MoveGroupCommand: ParsableCommand {
55
static var configuration = CommandConfiguration(
66
commandName: "move-group",
77
abstract: "Move a group to a different location within the project.",
8-
discussion: "Groups will be automatically merged if a group with the same name already exists at the destination. " +
9-
"When merging, files and subgroups will be combined.\n\n" +
10-
"If a file conflict occurs, existing files in the destination group will be preserved, " +
11-
"and the conflicting source files will be removed. A warning will be displayed to indicate the conflict."
8+
discussion: """
9+
- This command does not allow to move and rename the group at the same time.
10+
- Groups will be automatically merged if another group with the same name already exists at the destination.
11+
- When merging, files and subgroups will be combined.
12+
- If a file conflict occurs, existing files in the destination group will be preserved.
13+
- The conflicting source files will be moved with a ".bak" suffix.
14+
- A warning will be displayed to indicate the conflict.
15+
"""
1216
)
1317

1418
@OptionGroup
1519
var options: ProjectWriteOptions
1620

17-
@Option(name: .customLong("group"), help: "Path to group.")
21+
@Option(name: .customLong("group"), help: .init("Source group path.", valueName: "group-path"))
1822
var groupPath: String
1923

20-
@Option(name: .customLong("dest"), help: "Destination path.")
24+
@Option(
25+
name: .customLong("dest"),
26+
help: .init(
27+
"Destination group path. The whole source group will be moved into this path.",
28+
valueName: "group-path"
29+
)
30+
)
2131
var destination: String
2232

2333
func run() throws {

0 commit comments

Comments
 (0)