Giter Site home page Giter Site logo

go-flow's Introduction

go-flow

Run flow without any code!

Install

Requirement:

  • go
  • git
go get -v github.com/gogap/go-flow

Run your first flow

The config file of hello.conf

packages = ["github.com/flow-contrib/example/hello"]

app {
    name = "hello"
    usage = "This is a demo for run flow"

    commands {
        say {
            usage = "This command will print hello"

            default-config = { name = "gogap" }

            flow = ["example.hello", "example.hello"]
            
            config = {
              "1" = {
                 name = "Zeal"
            }
        }
    }
}
$ go-flow -v run --config hello.conf say

Hello: gogap
Hello: Zeal

Distribution your flow

$ go-flow build --config hello.conf

or

$ GOOS=linux GOARCH=amd64 go-flow build --config hello.conf

Just send the output binary ./hello to your firend, then He just input command:

$ ./hello say

Hello: gogap
Hello: Zeal

Advance Example

Subcommands

packages = ["github.com/flow-contrib/example/hello"]

app {
    name = "hello"
    usage = "This is a demo for run flow"

    commands {
        say {
            usage = "say something"

            gogap {
                usage = "This command will print hello"

                default-config = { name = "gogap" }

                flow = ["example.hello", "example.hello"]
                
                config = {
                  "1" = {
                     name = "Zeal"
                    }
                }
            }

            world {
                usage = "This command will print world"

                default-config = { name = "world" }

                flow = ["example.hello"]
                
                config = {}
            }
        }
    }
}
$ go-flow run --config hello.conf say
NAME:
   hello say - say something

USAGE:
   hello say command [command options] [arguments...]

COMMANDS:
     gogap  This command will print hello
     world  This command will print world
$ go-flow run --config hello.conf say gogap
Hello: gogap
Hello: Zeal
$ go-flow run --config hello.conf say world
Hello: world

Run javascript flow

goja.conf

packages = ["github.com/flow-contrib/goja"]

app {
	name = "goja"
	usage = ""

	commands {
		execute {
			usage = "execute javascript"

			default-config = {}

			flow = ["lang.javascript.goja?class=a", "lang.javascript.goja?class=b"]

			config {
				a = {src = A.js}
				b = {src = B.js}
			}
		}
	}
}

A.js

console.log("I am from A.js")

B.js

console.log("I am from B.js")
$ go-flow -v run --config goja.conf execute

2018/04/17 22:59:24 A.js
2018/04/17 22:59:24 B.js

Run ssh command on remote server

ssh.conf

packages = ["github.com/flow-contrib/toolkit/ssh"]

app {
    name = "ssh"
    usage = "This is a demo for run script on remote server"

    commands {
        run {
            usage = "Run command on remote ssh server"

            default-config = { 
            
                user = "user" 
                host = "localhost"
                port = "22"
                identity-file="/Users/gogap/.ssh/id_rsa"

                environment = ["GOPATH=/gopath"]
                command     = ["/bin/bash"]
                timeout     = 10s

                stdin ="""
                ping -c 1 example.com
                echo $GOPATH
                """

                quiet = false
                output.name = "ping-example" # set output name
            }

            flow = ["toolkit.ssh.run"]
        }
    }
}
$ go-flow run --config flow.conf run

PING example.com (93.184.216.34): 56 data bytes
64 bytes from 93.184.216.34: icmp_seq=0 ttl=46 time=267.681 ms
--- example.com ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 267.681/267.681/267.681/0.000 ms
/gopath

go-flow's People

Contributors

xujinzheng avatar

Stargazers

Beauty avatar  avatar bb8 avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

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.