├── LICENSE ├── README.md └── main.go /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Stephen Whitmore 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | 3 | None! `ipcat` doesn't require you to have a running local IPFS daemon. 4 | 5 | # Installation 6 | 7 | ``` 8 | $ go get github.com/noffle/ipcat 9 | 10 | $ ipcat QmQLBvJ3ur7U7mzbYDLid7WkaciY84SLpPYpGPHhDNps2Y 11 | "The man who makes no mistakes does not make anything." - Edward John Phelps 12 | ``` 13 | 14 | # Usage 15 | ``` 16 | Usage: ipcat IPFS_PATH 17 | 18 | Output IPFS object data to stdout. 19 | 20 | Arguments: 21 | IPFS_PATH="" the IPFS object path 22 | ``` 23 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | 8 | cli "github.com/jawher/mow.cli" 9 | fallback "github.com/noffle/fallback-ipfs-shell" 10 | ) 11 | 12 | func main() { 13 | cmd := cli.App("ipcat", "Retrieve IPFS object data and output it to stdout.") 14 | cmd.Spec = "IPFS_PATH" 15 | 16 | hash := cmd.String(cli.StringArg{ 17 | Name: "IPFS_PATH", 18 | Value: "", 19 | Desc: "the IPFS object path", 20 | }) 21 | 22 | cmd.Action = func() { 23 | if err := cat(*hash); err != nil { 24 | fmt.Fprintf(os.Stderr, "ipcat failed: %s\n", err) 25 | os.Exit(2) 26 | } 27 | } 28 | cmd.Run(os.Args) 29 | } 30 | 31 | func cat(path string) error { 32 | shell, err := fallback.NewShell() 33 | if err != nil { 34 | fmt.Fprintf(os.Stderr, "error: %s\n", err) 35 | os.Exit(1) 36 | } 37 | 38 | reader, err := shell.Cat(path) 39 | if err != nil { 40 | fmt.Fprintf(os.Stderr, "error: %s\n", err) 41 | os.Exit(1) 42 | } 43 | 44 | io.Copy(os.Stdout, reader) 45 | 46 | return nil 47 | } 48 | --------------------------------------------------------------------------------