hoi

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2018 License: MIT Imports: 14 Imported by: 1

README

Hoi

An easy file/message transfer tool using http file server.

Installation

Developer
$ go get github.com/monochromegane/hoi/...
User

Download from the following url.

Or, you can use Homebrew (Only MacOSX).

$ brew tap monochromegane/hoi
$ brew install hoi

Usage

Send file

You can build a download url.

$ hoi hoge.txt
http://192.168.0.100:8081/tx1lrmkkqenh5fy0izbassidb9t9l1na/hoge.txt

hoi links the file to ~/.hoi/temp_public/random, and it's document root directory for hoi server.

Send message
$ hoi message1 message2
http://192.168.0.100:8081/tx1lrmkkqenh5fy0izbassidb9t9l1na/message.txt

hoi create a message file to ~/.hoi/temp_public/random, and it's document root directory for hoi server.

Notify

You can notify the url to Slack account.

$ hoi file|message @user
http://192.168.0.100:8081/tx1lrmkkqenh5fy0izbassidb9t9l1na/message.txt
Message sent successfully to @user

Hoi supports Slack API and takosan (a simple web interface to Slack).

Configuration

hoi allows to change port number for hoi server

~/.hoi/conf.json

{
  "port": 8082
}

if you want to use notification for Slack:

{
  "notification": {
    "from":  "YOUR SLACK ACCOUNT",
    "to":    "slack",
    "token": "YOUR SLACK API TOKEN"
  }
}

or takosan:

{
  "notification": {
    "from": "YOUR SLACK ACCOUNT",
    "to":   "takosan",
    "host": "TAKOSAN HOST NAME",
    "port": TAKOSAN PORT NUMBER,
  }
}
Clear public directory
$ hoi --clear

Tasks

  • Add hoi server commands. (start|stop|status)
  • Add scheduler that clear public directory every some minutes.

Code status

wercker status

Build Status

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port         int          `json:"port"`
	Notification Notification `json:"notification"`
}

func Load

func Load(path string) Config

type Hoi

type Hoi struct {
	// contains filtered or unexported fields
}

func NewHoi

func NewHoi() *Hoi

func (Hoi) Clear

func (h Hoi) Clear()

func (Hoi) MakeMessage added in v0.1.3

func (h Hoi) MakeMessage(msgs []string) string

func (Hoi) MakePublic

func (h Hoi) MakePublic(file string) string

func (Hoi) Notify added in v0.1.3

func (h Hoi) Notify(to, message string) string

func (Hoi) Server

func (h Hoi) Server() *HoiServer

func (Hoi) TestFile added in v0.1.2

func (h Hoi) TestFile(file string) (string, error)

func (Hoi) ToUrl added in v0.1.3

func (h Hoi) ToUrl(path string) string

type HoiServer

type HoiServer struct {
	DocumentRoot string
	Port         int
}

func (HoiServer) Start

func (h HoiServer) Start()

func (HoiServer) Url

func (h HoiServer) Url() string

type Notification added in v0.1.3

type Notification struct {
	From  string `json:"from"`
	To    string `json:"to"`
	Host  string `json:"host"`
	Port  int    `json:"port"`
	Token string `json:"token"`
}

type Notifier added in v0.1.3

type Notifier interface {
	Notify(to, message string) error
}

func NewNotifier added in v0.1.3

func NewNotifier(conf Notification) Notifier

type Options

type Options struct {
	Server  bool `short:"s" long:"server" description:"Start hoi server."`
	Clear   bool `short:"c" long:"clear" description:"Clear all symlinks by removing contents under public directory."`
	Version bool `long:"version" description:"Show version"`
}

type SlackNotifier added in v0.1.3

type SlackNotifier struct {
	From   string
	Client *slack.Client
}

func (SlackNotifier) Notify added in v0.1.3

func (s SlackNotifier) Notify(to, message string) error

type TakosanNotifier added in v0.1.3

type TakosanNotifier struct {
	From string
	Host string
	Port int
}

func (TakosanNotifier) Notify added in v0.1.3

func (t TakosanNotifier) Notify(to, message string) error

Directories

Path Synopsis
cmd
hoi

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL