shell.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package embeddedShell
  2. import (
  3. "io"
  4. "github.com/ipfs/go-ipfs/core"
  5. "golang.org/x/net/context"
  6. )
  7. // Interface ...
  8. type Interface interface {
  9. // Add reads everything from the Reader and returns the IPFS hash
  10. Add(io.Reader) (string, error)
  11. // Cat returns a reader returning the data under the IPFS path
  12. Cat(path string) (io.ReadCloser, error)
  13. // AddDir(dir string) (string, error)
  14. // Get(hash string, outdir string) error
  15. // List(path string) ([]*LsLink, error)
  16. //FileList(path string) (*UnixLsObject, error)
  17. //FindPeer(peer string) (*PeerInfo, error)
  18. //ID(peer ...string) (*IdOutput, error)
  19. // Version() (string, string, error)
  20. // Refs(hash string, recursive bool) (<-chan string, error)
  21. // NewObject(template string) (string, error)
  22. // AddLink(target string) (string, error)
  23. // Patch(root string, action string, args ...string) (string, error)
  24. // PatchLink(root string, path string, childhash string, create bool) (string, error)
  25. // Pin(path string) error
  26. // Unpin(path string) error
  27. // Publish(node string, value string) error
  28. // Resolve(id string) (string, error)
  29. // ResolvePath(path string) (string, error)
  30. }
  31. // Shell ...
  32. type Shell struct {
  33. ctx context.Context
  34. node *core.IpfsNode
  35. }
  36. // func NewReadOnlyShell() *Shell {}
  37. func NewShell(node *core.IpfsNode) *Shell {
  38. return NewShellWithContext(node, context.Background())
  39. }
  40. func NewShellWithContext(node *core.IpfsNode, ctx context.Context) *Shell {
  41. return &Shell{ctx, node}
  42. }