Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add shebang support #7

Closed
twostraws opened this issue Jan 5, 2018 · 4 comments
Closed

Please add shebang support #7

twostraws opened this issue Jan 5, 2018 · 4 comments

Comments

@twostraws
Copy link

Unix scripts frequently start with a shebang/hashbang line like #!/bin/bash or #!/usr/bin/env python, which allows the rest of the script to be executed using a specific program.

This seems perfect for Beak: if I could use Beak in the shebang line then I could move hello.swift directly into /usr/local/bin/hello and run it using a command such as hello run release.

@yonaskolb
Copy link
Owner

This would probably require moving the --path param to before the subcommand, so an interpreter could easily parse the remaining arguments.

A simple shell script could then put placed somewhere which makes a beak call and passes the file as the --path. You could then reference that script in the shebang #!/usr/local/bin/beak-command

Is that what you mean? What support from beak would you want? An automatically installed interpreter?

@twostraws
Copy link
Author

Perhaps it's easier if I give a complete example. What I want is to be able to create a file like this:

#!/usr/bin/env beak

/// Releases the product
/// - Parameters:
///   - version: the version to release
public func release(version: String) throws {
    // implementation here
    print("version \(version) released!")
}

/// Installs the product
public func install() throws {
    // implementation here
    print("installed")
}

…then move that to /usr/local/bin/myapp, chmod a+x it, then run myapp run install. That would tell Beak "consider the rest of this as file your input, now please run its install() method."

@yonaskolb
Copy link
Owner

Yep, I understand. Now that I've moved the --path argument before the subcommand in master, you can simply adding this shebang #!/usr/bin/env beak --path.

@yonaskolb
Copy link
Owner

Resolved in 0.3.0. Let me know if you have any issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants