Giter Club home page Giter Club logo

script.swift's Introduction

Script.swift

Script.swift is a small library that lets you write a Swift script with ease by using method chaining, inspired by bitfield/script.

carbon-image

Install

Via Swift Package Manager

Add this line in dependencies of your Package.swift.

.package(url: "https://github.com/KS1019/Script.swift", from: "0.0.1")

Via swift-sh

Add this line at the top of your Swift script. Refer to swift-sh documentation for more details.

import ScriptSwift // KS1019/Script.swift ~> 0.0.1

Usage

Method Contents
exec Executes commands
ifExists Continues only if a file exists
write Writes data to a file
read Reads data from a file
countLines Returns the number of lines
concat Returns an array of string representation of files
asArray Returns lines of a string as an array

See documentation for more details.

Using Script.swift with swift-sh

When you want a script, you typically want it in a single file. With usual setup using Swift Package Manager to interact with external libraries, you would end up a directory with Package.swift, which is bit much as a script.

By using swift-sh, you only have to take care of a single Swift file for your script, which makes your Swift script as portable as possible.

Examples

Source Script

echo.swift

Script()
    .exec(#"echo "testing""#)
    .stdout()

Acknowledgements

script.swift's People

Contributors

ks1019 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

script.swift's Issues

Add `cd` as builtin

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.