cli: initial commit

this introduces the embd cli tool
This commit is contained in:
Karan Misra 2014-04-07 02:37:49 +05:30
parent c35deeb17c
commit ebfe2e5796
4 changed files with 73 additions and 2 deletions

View File

@ -13,9 +13,25 @@ Development sponsored by [**ThoughtWorks**](http://www.thoughtworks.com/)
* [Cubietruck](http://www.cubietruck.com/) **coming soon**
* Bring Your Own **coming soon**
## How to use
## The command line tool
Package embd provides a superheroic hardware abstraction layer for doing embedded programming
go get github.com/kidoman/embd/embd
will install a command line utility ```embd``` which will allow you to quickly get started with prototyping. The binary should be available in your ```$GOPATH/bin```. However, to be able to run this on a ARM based device, you will need to build it with ```GOOS=linux``` and ```GOARCH=arm``` environment variables set.
But, since I am feeling so generous, a prebuilt/tested version is available for direct download and deployment [here](https://dl.dropboxusercontent.com/u/6727135/Binaries/embd/linux-arm/embd).
For example, if you run ```embd detect``` on a **BeagleBone Black**:
root@beaglebone:~# embd detect
detected host BeagleBone Black (rev 0)
Run ```embd``` without any arguments to discover the various commands supported by the utility.
## How to use the framework
Package **embd** provides a hardware abstraction layer for doing embedded programming
on supported platforms like the Raspberry Pi and BeagleBone Black. Most of the examples below
will work without change (i.e. the same binary) on all supported platforms. How cool is that?

1
embd/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
embd

28
embd/detect.go Normal file
View File

@ -0,0 +1,28 @@
package main
import (
"fmt"
"os"
"github.com/codegangsta/cli"
"github.com/kidoman/embd"
)
func detect(c *cli.Context) {
host, rev, err := embd.DetectHost()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("detected host %v (rev %v)\n", host, rev)
}
var detectCmd = cli.Command{
Name: "detect",
Usage: "detect and display information about the host",
Action: detect,
}
func init() {
registerCommand(detectCmd)
}

26
embd/main.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"os"
"github.com/codegangsta/cli"
_ "github.com/kidoman/embd/host/all"
)
var version = "0.1.0"
var commands []cli.Command
func registerCommand(cmd cli.Command) {
commands = append(commands, cmd)
}
func main() {
app := cli.NewApp()
app.Name = "embd"
app.Usage = "superheroic embedded utility belt"
app.Version = version
app.Commands = commands
app.Run(os.Args)
}