Skip to content

Commit

Permalink
More cool CLI documentation and GH actions
Browse files Browse the repository at this point in the history
Signed-off-by: Henrik Panhans <henrik@panhans.dev>
  • Loading branch information
henrik-dmg committed Jan 19, 2024
1 parent 24785a0 commit 3529c77
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: Swift

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: swift build -v
- name: Run tests
run: swift test -v
2 changes: 1 addition & 1 deletion Sources/FileOrganiser/CustomParsableCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension CustomParsableCommand {
do {
try Organiser(fileHandler: fileHandler, logger: logger)
.process(
sourceURL: options.origin,
sourceURL: options.source,
destinationURL: options.destination,
globPattern: options.filePattern,
fileStrategy: strategy,
Expand Down
20 changes: 15 additions & 5 deletions Sources/FileOrganiser/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ import Foundation

struct Options: ParsableArguments {

@Argument(help: "The directory from which you want to copy or move files", transform: URL.init(fileURLWithPath:))
var origin: URL

@Argument(help: "The directory matched files will be copied or moved to", transform: URL.init(fileURLWithPath:))
@Argument(
help: "The directory from which you want to copy or move files",
completion: .directory,
transform: URL.init(fileURLWithPath:)
)
var source: URL

@Argument(help: "The directory matched files will be copied or moved to", completion: .directory, transform: URL.init(fileURLWithPath:))
var destination: URL

@Option(help: "An optional name pattern to match files against. Only matched files will be moved or copied")
var filePattern: String?

@Option(help: "The strategy with which files are grouped into subfolders. Use either \"year\", \"month\", \"week\" or \"day\". For more information, please visit")
@Option(
help: """
The strategy with which files are grouped into subfolders.
For more information, please visit https://github.com/henrik-dmg/FileOrganiser#date-grouping-strategies
""",
completion: .list(DateGroupingStrategy.allCases.map({ $0.rawValue }))
)
var dateStrategy: DateGroupingStrategy = .month

@Flag(help: "Only print the actions that would be performed, but do not actually perform them")
Expand Down
2 changes: 1 addition & 1 deletion Sources/FileOrganiserKit/Strategy.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public enum DateGroupingStrategy: String, Codable {
public enum DateGroupingStrategy: String, Codable, CaseIterable {
case year, month, week, day
}

Expand Down
3 changes: 2 additions & 1 deletion Tests/FileOrganiserKitTests/OrganiserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ final class OrganiserTests: XCTestCase {
globPattern: glob,
fileStrategy: fileStrategy,
dateStrategy: dateStrategy,
dryRun: dryRun
dryRun: dryRun,
shouldSoftFail: false
)
}

Expand Down

0 comments on commit 3529c77

Please sign in to comment.