Skip to content

A Swift/Shell DSL using dynamicCallable and dynamicMemberLookup

Notifications You must be signed in to change notification settings

maxchuquimia/cockle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cockle

Run any shell commands as if they were a prebuilt Swift function using the magic of @dynamicCallable and @dynamicMemberLookup. Simply use underscores instead of dashes!

The cool names ShellSwift, Shift, Swell, Swsh, Swish, ShellKit and SwiftyShell were already taken 😭

Examples

Cloning a Git repo

let shell = try Shell()

try shell.git(
    clone: (),
    __depth: 5,
    __branch: "develop",
    "https://github.com/org/cool-repo.git "
)

try shell.cd("cool-repo")

let history = try shell.git(log: (), __oneline: ())

Archiving using Xcodebuild

let shell = try Shell()

try shell.xcodebuild(
    archive: (),
    _project: "CoolApp.xcodeproj",
    _scheme: "CoolApp-Prod",
    _archivePath: "/tmp/output.xcarchive"
)

Creating some files

let shell = try Shell()

try shell.mkdir(_p: "cockle/example")

for ext in [".txt", ".swift", ".md"] {
    try shell.touch("cockle/example/Hello" + ext)
}

let allFiles = try shell.ls(_l: (), _a: ())
print(allFiles.lines)

About

A Swift/Shell DSL using dynamicCallable and dynamicMemberLookup

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages