Update package name in source files
authorMikael Berthe <mikael@lilotux.net>
Wed, 19 Apr 2017 10:43:38 +0200
changeset 138 23d3a518d0ad
parent 137 acaea3179f4d
child 139 7145e95b4f57
Update package name in source files Also remove the cmd subdirectory and all empty tests.
account.go
account_test.go
api.go
app.go
app_test.go
client.go
client_test.go
cmd/gondole-cli/config.go
cmd/gondole-cli/config_test.go
cmd/gondole-cli/main.go
cmd/gondole-cli/test/config.toml
cmd/gondole-cli/test/foo.token
cmd/gondole-cli/test/garbage.token
cmd/gondole-cli/test/perms.toml
cmd/gondole-cli/utils.go
cmd/gondole-cli/utils_test.go
favourites.go
gondole.go
gondole_test.go
instance.go
login.go
madon.go
madon_test.go
media.go
notifications.go
report.go
report_test.go
search.go
status.go
status_test.go
streams.go
timelines.go
types.go
--- a/account.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/account.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,7 +4,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"fmt"
@@ -28,7 +28,7 @@
 // "unfollow", "block", "unblock", "mute", "unmute",
 // "follow_requests/authorize" or // "follow_requests/reject".
 // The id is optional and depends on the operation.
-func (g *Client) getSingleAccount(op string, id int) (*Account, error) {
+func (mc *Client) getSingleAccount(op string, id int) (*Account, error) {
 	var endPoint string
 	method := rest.Get
 	strID := strconv.Itoa(id)
@@ -51,7 +51,7 @@
 	}
 
 	var account Account
-	if err := g.apiCall(endPoint, method, nil, &account); err != nil {
+	if err := mc.apiCall(endPoint, method, nil, &account); err != nil {
 		return nil, err
 	}
 	return &account, nil
@@ -61,7 +61,7 @@
 // The operation 'op' can be "followers", "following", "search", "blocks",
 // "mutes", "follow_requests".
 // The id is optional and depends on the operation.
-func (g *Client) getMultipleAccounts(op string, opts *getAccountsOptions) ([]Account, error) {
+func (mc *Client) getMultipleAccounts(op string, opts *getAccountsOptions) ([]Account, error) {
 	var endPoint string
 
 	switch op {
@@ -91,7 +91,7 @@
 	}
 
 	var accounts []Account
-	if err := g.apiCall(endPoint, rest.Get, params, &accounts); err != nil {
+	if err := mc.apiCall(endPoint, rest.Get, params, &accounts); err != nil {
 		return nil, err
 	}
 	return accounts, nil
@@ -100,8 +100,8 @@
 // GetAccount returns an account entity
 // The returned value can be nil if there is an error or if the
 // requested ID does not exist.
-func (g *Client) GetAccount(accountID int) (*Account, error) {
-	account, err := g.getSingleAccount("account", accountID)
+func (mc *Client) GetAccount(accountID int) (*Account, error) {
+	account, err := mc.getSingleAccount("account", accountID)
 	if err != nil {
 		return nil, err
 	}
@@ -112,8 +112,8 @@
 }
 
 // GetCurrentAccount returns the current user account
-func (g *Client) GetCurrentAccount() (*Account, error) {
-	account, err := g.getSingleAccount("verify_credentials", 0)
+func (mc *Client) GetCurrentAccount() (*Account, error) {
+	account, err := mc.getSingleAccount("verify_credentials", 0)
 	if err != nil {
 		return nil, err
 	}
@@ -124,20 +124,20 @@
 }
 
 // GetAccountFollowers returns the list of accounts following a given account
-func (g *Client) GetAccountFollowers(accountID int) ([]Account, error) {
+func (mc *Client) GetAccountFollowers(accountID int) ([]Account, error) {
 	o := &getAccountsOptions{ID: accountID}
-	return g.getMultipleAccounts("followers", o)
+	return mc.getMultipleAccounts("followers", o)
 }
 
 // GetAccountFollowing returns the list of accounts a given account is following
-func (g *Client) GetAccountFollowing(accountID int) ([]Account, error) {
+func (mc *Client) GetAccountFollowing(accountID int) ([]Account, error) {
 	o := &getAccountsOptions{ID: accountID}
-	return g.getMultipleAccounts("following", o)
+	return mc.getMultipleAccounts("following", o)
 }
 
 // FollowAccount follows an account
-func (g *Client) FollowAccount(accountID int) error {
-	account, err := g.getSingleAccount("follow", accountID)
+func (mc *Client) FollowAccount(accountID int) error {
+	account, err := mc.getSingleAccount("follow", accountID)
 	if err != nil {
 		return err
 	}
@@ -148,8 +148,8 @@
 }
 
 // UnfollowAccount unfollows an account
-func (g *Client) UnfollowAccount(accountID int) error {
-	account, err := g.getSingleAccount("unfollow", accountID)
+func (mc *Client) UnfollowAccount(accountID int) error {
+	account, err := mc.getSingleAccount("unfollow", accountID)
 	if err != nil {
 		return err
 	}
@@ -160,8 +160,8 @@
 }
 
 // FollowRemoteAccount follows a remote account
-// The parameter 'uri' is a URI (e.g. "username@domain").
-func (g *Client) FollowRemoteAccount(uri string) (*Account, error) {
+// The parameter 'uri' is a URI (e.mc. "username@domain").
+func (mc *Client) FollowRemoteAccount(uri string) (*Account, error) {
 	if uri == "" {
 		return nil, ErrInvalidID
 	}
@@ -170,7 +170,7 @@
 	params["uri"] = uri
 
 	var account Account
-	if err := g.apiCall("follows", rest.Post, params, &account); err != nil {
+	if err := mc.apiCall("follows", rest.Post, params, &account); err != nil {
 		return nil, err
 	}
 	if account.ID == 0 {
@@ -180,8 +180,8 @@
 }
 
 // BlockAccount blocks an account
-func (g *Client) BlockAccount(accountID int) error {
-	account, err := g.getSingleAccount("block", accountID)
+func (mc *Client) BlockAccount(accountID int) error {
+	account, err := mc.getSingleAccount("block", accountID)
 	if err != nil {
 		return err
 	}
@@ -192,8 +192,8 @@
 }
 
 // UnblockAccount unblocks an account
-func (g *Client) UnblockAccount(accountID int) error {
-	account, err := g.getSingleAccount("unblock", accountID)
+func (mc *Client) UnblockAccount(accountID int) error {
+	account, err := mc.getSingleAccount("unblock", accountID)
 	if err != nil {
 		return err
 	}
@@ -204,8 +204,8 @@
 }
 
 // MuteAccount mutes an account
-func (g *Client) MuteAccount(accountID int) error {
-	account, err := g.getSingleAccount("mute", accountID)
+func (mc *Client) MuteAccount(accountID int) error {
+	account, err := mc.getSingleAccount("mute", accountID)
 	if err != nil {
 		return err
 	}
@@ -216,8 +216,8 @@
 }
 
 // UnmuteAccount unmutes an account
-func (g *Client) UnmuteAccount(accountID int) error {
-	account, err := g.getSingleAccount("unmute", accountID)
+func (mc *Client) UnmuteAccount(accountID int) error {
+	account, err := mc.getSingleAccount("unmute", accountID)
 	if err != nil {
 		return err
 	}
@@ -229,28 +229,28 @@
 
 // SearchAccounts returns a list of accounts matching the query string
 // The limit parameter is optional (can be 0).
-func (g *Client) SearchAccounts(query string, limit int) ([]Account, error) {
+func (mc *Client) SearchAccounts(query string, limit int) ([]Account, error) {
 	o := &getAccountsOptions{Q: query, Limit: limit}
-	return g.getMultipleAccounts("search", o)
+	return mc.getMultipleAccounts("search", o)
 }
 
 // GetBlockedAccounts returns the list of blocked accounts
-func (g *Client) GetBlockedAccounts() ([]Account, error) {
-	return g.getMultipleAccounts("blocks", nil)
+func (mc *Client) GetBlockedAccounts() ([]Account, error) {
+	return mc.getMultipleAccounts("blocks", nil)
 }
 
 // GetMutedAccounts returns the list of muted accounts
-func (g *Client) GetMutedAccounts() ([]Account, error) {
-	return g.getMultipleAccounts("mutes", nil)
+func (mc *Client) GetMutedAccounts() ([]Account, error) {
+	return mc.getMultipleAccounts("mutes", nil)
 }
 
 // GetAccountFollowRequests returns the list of follow requests accounts
-func (g *Client) GetAccountFollowRequests() ([]Account, error) {
-	return g.getMultipleAccounts("follow_requests", nil)
+func (mc *Client) GetAccountFollowRequests() ([]Account, error) {
+	return mc.getMultipleAccounts("follow_requests", nil)
 }
 
 // GetAccountRelationships returns a list of relationship entities for the given accounts
-func (g *Client) GetAccountRelationships(accountIDs []int) ([]Relationship, error) {
+func (mc *Client) GetAccountRelationships(accountIDs []int) ([]Relationship, error) {
 	if len(accountIDs) < 1 {
 		return nil, ErrInvalidID
 	}
@@ -265,7 +265,7 @@
 	}
 
 	var rl []Relationship
-	if err := g.apiCall("accounts/relationships", rest.Get, params, &rl); err != nil {
+	if err := mc.apiCall("accounts/relationships", rest.Get, params, &rl); err != nil {
 		return nil, err
 	}
 	return rl, nil
@@ -274,7 +274,7 @@
 // GetAccountStatuses returns a list of status entities for the given account
 // If onlyMedia is true, returns only statuses that have media attachments.
 // If excludeReplies is true, skip statuses that reply to other statuses.
-func (g *Client) GetAccountStatuses(accountID int, onlyMedia, excludeReplies bool) ([]Status, error) {
+func (mc *Client) GetAccountStatuses(accountID int, onlyMedia, excludeReplies bool) ([]Status, error) {
 	if accountID < 1 {
 		return nil, ErrInvalidID
 	}
@@ -289,18 +289,18 @@
 	}
 
 	var sl []Status
-	if err := g.apiCall(endPoint, rest.Get, params, &sl); err != nil {
+	if err := mc.apiCall(endPoint, rest.Get, params, &sl); err != nil {
 		return nil, err
 	}
 	return sl, nil
 }
 
 // FollowRequestAuthorize authorizes or rejects an account follow-request
-func (g *Client) FollowRequestAuthorize(accountID int, authorize bool) error {
+func (mc *Client) FollowRequestAuthorize(accountID int, authorize bool) error {
 	endPoint := "follow_requests/reject"
 	if authorize {
 		endPoint = "follow_requests/authorize"
 	}
-	_, err := g.getSingleAccount(endPoint, accountID)
+	_, err := mc.getSingleAccount(endPoint, accountID)
 	return err
 }
--- a/account_test.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-package gondole
--- a/api.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/api.go	Wed Apr 19 10:43:38 2017 +0200
@@ -5,7 +5,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"bytes"
@@ -76,20 +76,20 @@
 }
 
 // prepareRequest inserts all pre-defined stuff
-func (g *Client) prepareRequest(target string, method rest.Method, params apiCallParams) (rest.Request, error) {
+func (mc *Client) prepareRequest(target string, method rest.Method, params apiCallParams) (rest.Request, error) {
 	var req rest.Request
 
-	if g == nil {
-		return req, fmt.Errorf("use of uninitialized gondole client")
+	if mc == nil {
+		return req, ErrUninitializedClient
 	}
 
-	endPoint := g.APIBase + "/" + target
+	endPoint := mc.APIBase + "/" + target
 
 	// Request headers
 	hdrs := make(map[string]string)
-	hdrs["User-Agent"] = fmt.Sprintf("Gondole/%s", GondoleVersion)
-	if g.UserToken != nil {
-		hdrs["Authorization"] = fmt.Sprintf("Bearer %s", g.UserToken.AccessToken)
+	hdrs["User-Agent"] = fmt.Sprintf("madon/%s", MadonVersion)
+	if mc.UserToken != nil {
+		hdrs["Authorization"] = fmt.Sprintf("Bearer %s", mc.UserToken.AccessToken)
 	}
 
 	req = rest.Request{
@@ -102,13 +102,13 @@
 }
 
 // apiCall makes a call to the Mastodon API server
-func (g *Client) apiCall(endPoint string, method rest.Method, params apiCallParams, data interface{}) error {
-	if g == nil {
-		return fmt.Errorf("use of uninitialized gondole client")
+func (mc *Client) apiCall(endPoint string, method rest.Method, params apiCallParams, data interface{}) error {
+	if mc == nil {
+		return fmt.Errorf("use of uninitialized madon client")
 	}
 
 	// Prepare query
-	req, err := g.prepareRequest(endPoint, method, params)
+	req, err := mc.prepareRequest(endPoint, method, params)
 	if err != nil {
 		return err
 	}
--- a/app.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/app.go	Wed Apr 19 10:43:38 2017 +0200
@@ -5,7 +5,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"errors"
@@ -46,13 +46,13 @@
 }
 
 // NewApp registers a new application with a given instance
-func NewApp(name string, scopes []string, redirectURI, instanceName string) (g *Client, err error) {
+func NewApp(name string, scopes []string, redirectURI, instanceName string) (mc *Client, err error) {
 	instanceURL, err := buildInstanceURL(instanceName)
 	if err != nil {
 		return nil, err
 	}
 
-	g = &Client{
+	mc = &Client{
 		Name:        name,
 		InstanceURL: instanceURL,
 		APIBase:     instanceURL + currentAPIPath,
@@ -68,18 +68,18 @@
 	}
 
 	var app registerApp
-	if err := g.apiCall("apps", rest.Post, params, &app); err != nil {
+	if err := mc.apiCall("apps", rest.Post, params, &app); err != nil {
 		return nil, err
 	}
 
-	g.ID = app.ClientID
-	g.Secret = app.ClientSecret
+	mc.ID = app.ClientID
+	mc.Secret = app.ClientSecret
 
 	return
 }
 
 // RestoreApp recreates an application client with existing secrets
-func RestoreApp(name, instanceName, appID, appSecret string, userToken *UserToken) (g *Client, err error) {
+func RestoreApp(name, instanceName, appID, appSecret string, userToken *UserToken) (mc *Client, err error) {
 	instanceURL, err := buildInstanceURL(instanceName)
 	if err != nil {
 		return nil, err
--- a/app_test.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package gondole
-
-import (
-	"testing"
-	//"github.com/stretchr/testify/assert"
-)
-
-func TestNewApp(t *testing.T) {
-	//g, err := NewApp("gondole-cli", ourScopes, NoRedirect)
-	//assert.NoError(t, err, "no error")
-	//assert.Equal(t, "gondole-cli", g.Name, "should be equal")
-}
--- a/client.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-package gondole
--- a/client_test.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-package gondole
--- a/cmd/gondole-cli/config.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-// config.go
-//
-// This file implements the configuration part for when you need the API
-// key to modify things in the Mastodon configuration and manage measurements.
-
-package main
-
-import (
-	"fmt"
-	"io/ioutil"
-	"log"
-	"os"
-	"path/filepath"
-
-	"github.com/naoina/toml"
-)
-
-/*
-Assume the application is registered if $HOME/.config/<gondole>/config.toml already exist
-We will store the per-instance token into $HOME/.config/<gondole>/<site>.token
-*/
-
-const (
-	DefaultName = "config.toml"
-)
-
-var (
-	baseDir = filepath.Join(os.Getenv("HOME"),
-		".config",
-		"gondole",
-	)
-)
-
-func loadGlobal(file string) (c *Config, err error) {
-	log.Printf("file=%s", file)
-	// Check if there is any config file
-	_, err = os.Stat(file)
-	if err != nil {
-		return
-	}
-
-	log.Printf("file=%s, found it", file)
-	// Read it
-	buf, err := ioutil.ReadFile(file)
-	if err != nil {
-		return c, fmt.Errorf("Can not read %s", file)
-	}
-
-	cnf := Config{}
-	err = toml.Unmarshal(buf, &cnf)
-	if err != nil {
-		return c, fmt.Errorf("Error parsing toml %s: %v", file, err)
-	}
-	c = &cnf
-	return
-}
-
-func loadInstance(name string) (s *Server, err error) {
-	// Load instance-specific file
-	file := filepath.Join(baseDir, name+".token")
-
-	log.Printf("instance is %s", file)
-
-	// Check if there is any config file
-	if _, err = os.Stat(file); err == nil {
-		// Read it
-		buf, err := ioutil.ReadFile(file)
-		if err != nil {
-			return s, fmt.Errorf("Can not read %s", file)
-		}
-
-		sc := Server{}
-		err = toml.Unmarshal(buf, &sc)
-		if err != nil {
-			return s, fmt.Errorf("Error parsing toml %s: %v", file, err)
-		}
-		s = &sc
-	}
-	return
-}
-
-func GetInstanceList() (list []string) {
-	list, err := filepath.Glob(filepath.Join(baseDir, "*.token"))
-	log.Printf("basedir=%s", filepath.Join(baseDir, "*.token"))
-	if err != nil {
-		log.Printf("warning, no *.token files in %s", baseDir)
-		list = nil
-	}
-	log.Printf("list=%v", list)
-	return
-}
-
-// LoadConfig reads a file as a TOML document and return the structure
-func LoadConfig(name string) (s *Server, err error) {
-	// Load global file
-	gFile := filepath.Join(baseDir, DefaultName)
-
-	log.Printf("global is %s", gFile)
-	c, err := loadGlobal(gFile)
-	if err != nil {
-		return
-	}
-	if name == "" {
-		s, err = loadInstance(c.Default)
-	} else {
-		s, err = loadInstance(name)
-	}
-
-	return s, err
-}
-
-func (c *Config) Write() (err error) {
-	if err = os.MkdirAll(baseDir, 0700); err != nil {
-		log.Fatalf("error creating configuration directory: %s", baseDir)
-	}
-
-	var sc []byte
-
-	if sc, err = toml.Marshal(*c); err != nil {
-		log.Fatalf("error saving configuration")
-	}
-	err = ioutil.WriteFile(filepath.Join(baseDir, DefaultName), sc, 0600)
-	return
-}
-
-func (s *Server) WriteToken(instance string) (err error) {
-	if err = os.MkdirAll(baseDir, 0700); err != nil {
-		log.Fatalf("error creating configuration directory: %s", baseDir)
-	}
-
-	var sc []byte
-
-	if sc, err = toml.Marshal(s); err != nil {
-		log.Fatalf("error saving configuration")
-	}
-
-	full := instance + ".token"
-	err = ioutil.WriteFile(filepath.Join(baseDir, full), sc, 0600)
-	return
-}
--- a/cmd/gondole-cli/config_test.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-package main
-
-import (
-	"github.com/stretchr/testify/assert"
-	"os"
-	"path/filepath"
-	"testing"
-)
-
-func TestLoadGlobal(t *testing.T) {
-	baseDir = "."
-
-	_, err := loadGlobal(filepath.Join("test", "non.toml"))
-	assert.Error(t, err, "does not exist")
-
-	_, err = loadGlobal(filepath.Join("test", "garbage.token"))
-	assert.Error(t, err, "just garbage")
-
-	// git does now allow you to checkin 000 files :(
-	err = os.Chmod(filepath.Join("test", "perms.toml"), 0000)
-	assert.NoError(t, err, "should be fine")
-	_, err = loadGlobal(filepath.Join("test", "perms.toml"))
-	assert.Error(t, err, "unreadable")
-	err = os.Chmod(filepath.Join("test", "perms.toml"), 0600)
-	assert.NoError(t, err, "should be fine")
-
-	c, err := loadGlobal(filepath.Join("test", "config.toml"))
-	assert.NoError(t, err, "should read it fine")
-	assert.EqualValues(t, "foo", c.Default, "equal")
-}
-
-func TestLoadInstance(t *testing.T) {
-	baseDir = "."
-
-	_, err := loadInstance("nonexistent")
-	assert.Error(t, err, "does not exist")
-
-	file := filepath.Join("test", "garbage")
-	_, err = loadInstance(file)
-	assert.Error(t, err, "just garbage")
-
-	file = filepath.Join("test", "foo.token")
-	err = os.Chmod(file, 0000)
-	assert.NoError(t, err, "should be fine")
-
-	file = filepath.Join("test", "foo")
-	_, err = loadInstance(file)
-	assert.Error(t, err, "unreadable")
-
-	file = filepath.Join("test", "foo.token")
-	err = os.Chmod(file, 0644)
-	assert.NoError(t, err, "should be fine")
-
-	real := &Server{
-		ID:          "666abcdef666",
-		Name:        "foo",
-		BearerToken: "d3b07384d113edec49eaa6238ad5ff00",
-		APIBase:     "https://mastodon.social/api/v1",
-		InstanceURL: "https://mastodon.social",
-	}
-	file = filepath.Join("test", "foo")
-	s, err := loadInstance(file)
-	assert.NoError(t, err, "all fine")
-	assert.Equal(t, real, s, "equal")
-}
-
-func TestGetInstanceList(t *testing.T) {
-	baseDir = "test"
-
-	real := []string{
-		filepath.Join("test", "foo.token"),
-		filepath.Join("test", "garbage.token"),
-	}
-	list := GetInstanceList()
-	assert.Equal(t, real, list, "equal")
-
-	baseDir = "/tmp"
-	real = nil
-	list = GetInstanceList()
-	assert.Equal(t, real, list, "equal")
-
-	baseDir = "/nonexistent"
-	real = nil
-	list = GetInstanceList()
-	assert.Equal(t, real, list, "equal")
-}
-
-func TestLoadConfig(t *testing.T) {
-	baseDir = "test"
-
-	_, err := LoadConfig("foo")
-	assert.NoError(t, err, "should be fine")
-
-	_, err = LoadConfig("")
-	assert.NoError(t, err, "should be fine")
-
-	err = os.Chmod(filepath.Join("test", "config.toml"), 0000)
-	assert.NoError(t, err, "should be fine")
-
-	_, err = LoadConfig("")
-	assert.Error(t, err, "should be unreadable")
-
-	err = os.Chmod(filepath.Join("test", "config.toml"), 0600)
-	assert.NoError(t, err, "should be fine")
-
-}
--- a/cmd/gondole-cli/main.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,197 +0,0 @@
-package main
-
-import (
-	"log"
-	"os"
-	"strings"
-
-	"github.com/urfave/cli"
-
-	"github.com/McKael/gondole"
-)
-
-var (
-	fVerbose             bool
-	fInstance            string
-	fAuthMethod          string
-	fUsername, fPassword string
-	fScopes              string
-
-	instance *gondole.Client
-	cnf      *Server
-
-	// Default scopes
-	ourScopes = []string{
-		"read",
-		"write",
-		"follow",
-	}
-
-	defaultInstanceURL = "https://mastodon.social"
-
-	authMethods = map[string]bool{
-		"basic":  true,
-		"oauth2": true,
-	}
-)
-
-// Server holds our application details
-type Server struct {
-	ID          string `json:"id"`
-	Name        string `json:"name"`
-	BearerToken string `json:"bearer_token"`
-	APIBase     string `json:"base_url"`
-	InstanceURL string `json:"instance_url"`
-}
-
-type Config struct {
-	Default string
-
-	// Can be "oauth2", "basic"
-	Auth string
-
-	// If not using OAuth2
-	User     string
-	Password string
-}
-
-func setupEnvironment(c *cli.Context) (err error) {
-	var config Config
-	var scopes []string
-
-	instanceURL := defaultInstanceURL
-	if fInstance != "" {
-		if strings.Contains(fInstance, "://") {
-			instanceURL = fInstance
-		} else {
-			instanceURL = "https://" + fInstance
-		}
-	}
-
-	instanceName := basename(instanceURL)
-
-	if fAuthMethod != "" && authMethods[fAuthMethod] {
-
-	}
-
-	// Set scopes
-	if fScopes != "" {
-		scopes = strings.Split(fScopes, " ")
-	} else {
-		scopes = ourScopes
-	}
-
-	// Load configuration, will register if none is found
-	cnf, err = LoadConfig(instanceName)
-	if err == nil && cnf != nil {
-		instance = &gondole.Client{
-			ID:          cnf.ID,
-			InstanceURL: cnf.InstanceURL,
-			APIBase:     cnf.APIBase,
-			Name:        cnf.Name,
-			Secret:      cnf.BearerToken,
-		}
-	} else {
-		// Nothing exist yet
-		/*
-			defName := Config{
-				Default:  instanceName,
-				Auth:     "basic",
-				User:     "",
-				Password: "",
-			}
-		*/
-
-		err = config.Write()
-		if err != nil {
-			log.Fatalf("error: can not write config for %s", instanceName)
-		}
-
-		instance, err = gondole.NewApp("gondole-cli", scopes, gondole.NoRedirect, instanceURL)
-		if err != nil {
-			log.Fatalf("error: can not register application:", err.Error())
-		}
-
-		server := &Server{
-			ID:          instance.ID,
-			Name:        instance.Name,
-			BearerToken: instance.Secret,
-			APIBase:     instance.APIBase,
-			InstanceURL: instance.InstanceURL,
-		}
-		err = server.WriteToken(instanceName)
-		if err != nil {
-			log.Fatalf("error: can not write token for %s", instance.Name)
-		}
-
-		cnf := Config{
-			Default: instance.Name,
-		}
-
-		err = cnf.Write()
-		if err != nil {
-			log.Fatalf("error: can not write config for %s", instance.Name)
-		}
-	}
-
-	// Log in to the instance
-	if fAuthMethod != "oauth2" {
-		err = instance.LoginBasic(fUsername, fPassword, scopes)
-	}
-
-	return err
-}
-
-func init() {
-	cli.VersionFlag = cli.BoolFlag{Name: "version, V"}
-
-	cli.VersionPrinter = func(c *cli.Context) {
-		log.Printf("API wrapper: %s Mastodon CLI: %s\n", c.App.Version, gondole.GondoleVersion)
-	}
-}
-
-func main() {
-
-	app := cli.NewApp()
-	app.Name = "gondole"
-	app.Usage = "Mastodon CLI interface"
-	app.Author = "Ollivier Robert <roberto@keltia.net>"
-	app.Version = gondole.GondoleVersion
-	//app.HideVersion = true
-
-	app.Before = setupEnvironment
-
-	app.Flags = []cli.Flag{
-		cli.StringFlag{
-			Name:        "auth,A",
-			Usage:       "authentication mode",
-			Destination: &fAuthMethod,
-		},
-		cli.StringFlag{
-			Name:        "instance,I",
-			Usage:       "use that instance",
-			Destination: &fInstance,
-		},
-		cli.StringFlag{
-			Name:        "scopes,S",
-			Usage:       "use these scopes",
-			Destination: &fScopes,
-		},
-		cli.StringFlag{
-			Name:        "username,login",
-			Usage:       "user name",
-			Destination: &fUsername,
-		},
-		cli.StringFlag{
-			Name:        "password",
-			Usage:       "user password",
-			Destination: &fPassword,
-		},
-		cli.BoolFlag{
-			Name:        "verbose,v",
-			Usage:       "verbose mode",
-			Destination: &fVerbose,
-		},
-	}
-	app.Run(os.Args)
-}
--- a/cmd/gondole-cli/test/config.toml	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-default="foo"
--- a/cmd/gondole-cli/test/foo.token	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-id = "666abcdef666"
-name = "foo"
-bearer_token = "d3b07384d113edec49eaa6238ad5ff00"
-api_base = "https://mastodon.social/api/v1"
-instance_url = "https://mastodon.social"
--- a/cmd/gondole-cli/test/garbage.token	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
->'''(fsljfùùksdjlf1656>
--- a/cmd/gondole-cli/utils.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-package main
-
-import (
-	"github.com/urfave/cli"
-	"net/url"
-	"strings"
-)
-
-// ByAlphabet is for sorting
-type ByAlphabet []cli.Command
-
-func (a ByAlphabet) Len() int           { return len(a) }
-func (a ByAlphabet) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
-func (a ByAlphabet) Less(i, j int) bool { return a[i].Name < a[j].Name }
-
-func filterURL(in string) (out string) {
-	uri, err := url.Parse(in)
-	if err != nil {
-		out = ""
-	} else {
-		uri := url.URL{Scheme: uri.Scheme, Host: uri.Host}
-		out = uri.String()
-	}
-	return
-}
-
-func basename(in string) (out string) {
-	uri, err := url.Parse(in)
-	if err != nil {
-		out = ""
-	} else {
-		// Remove the :NN part of present
-		out = strings.Split(uri.Host, ":")[0]
-	}
-	return
-}
--- a/cmd/gondole-cli/utils_test.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-package main
-
-import (
-    "testing"
-    "github.com/stretchr/testify/assert"
-)
-
-func TestFilterURL(t *testing.T) {
-    in := "https://example.com"
-    out := filterURL(in)
-    assert.EqualValues(t, in, out, "equal")
-}
-
-func TestBasename(t *testing.T) {
-    in := "https://example.com"
-    out := basename(in)
-    assert.EqualValues(t, "example.com", out, "equal")
-
-    in = "https://example.com:80"
-    out = basename(in)
-    assert.EqualValues(t, "example.com", out, "equal")
-
-    in = "https://example.com:16443"
-    out = basename(in)
-    assert.EqualValues(t, "example.com", out, "equal")
-
-    in = "//example.com:443"
-    out = basename(in)
-    assert.EqualValues(t, "example.com", out, "equal")
-}
--- a/favourites.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/favourites.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,16 +4,16 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"github.com/sendgrid/rest"
 )
 
 // GetFavourites returns the list of the user's favourites
-func (g *Client) GetFavourites() ([]Status, error) {
+func (mc *Client) GetFavourites() ([]Status, error) {
 	var faves []Status
-	err := g.apiCall("favourites", rest.Get, nil, &faves)
+	err := mc.apiCall("favourites", rest.Get, nil, &faves)
 	if err != nil {
 		return nil, err
 	}
--- a/gondole.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
-Copyright 2017 Ollivier Robert
-Copyright 2017 Mikael Berthe
-
-Licensed under the MIT license.  Please see the LICENSE file is this directory.
-*/
-
-package gondole
-
-import (
-	"errors"
-)
-
-// apiCallParams is a map with the parameters for an API call
-type apiCallParams map[string]string
-
-const (
-	// GondoleVersion contains the version of the Gondole implementation
-	GondoleVersion = "0.1"
-
-	// API version implemented in this library
-	apiVersion     = "v1"
-	currentAPIPath = "/api/" + apiVersion
-
-	// NoRedirect is the URI for no redirection in the App registration
-	NoRedirect = "urn:ietf:wg:oauth:2.0:oob"
-)
-
-// Error codes
-var (
-	ErrAlreadyRegistered = errors.New("app already registered")
-	ErrEntityNotFound    = errors.New("entity not found")
-	ErrInvalidParameter  = errors.New("incorrect parameter")
-	ErrInvalidID         = errors.New("incorrect entity ID")
-)
--- a/gondole_test.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-package gondole
-
-import (
-	"testing"
-
-	"github.com/sendgrid/rest"
-	"github.com/stretchr/testify/assert"
-)
-
-func TestPrepareRequest(t *testing.T) {
-	g := &Client{
-		Name:    "foo",
-		ID:      "666",
-		Secret:  "biiiip",
-		APIBase: "http://example.com",
-	}
-
-	req, err := g.prepareRequest("bar", rest.Get, nil)
-	assert.NoError(t, err, "no error")
-	assert.NotNil(t, req.Headers, "not nil")
-}
--- a/instance.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/instance.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,16 +4,16 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"github.com/sendgrid/rest"
 )
 
 // GetCurrentInstance returns current instance information
-func (g *Client) GetCurrentInstance() (*Instance, error) {
+func (mc *Client) GetCurrentInstance() (*Instance, error) {
 	var i Instance
-	if err := g.apiCall("instance", rest.Get, nil, &i); err != nil {
+	if err := mc.apiCall("instance", rest.Get, nil, &i); err != nil {
 		return nil, err
 	}
 	return &i, nil
--- a/login.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/login.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,7 +4,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"encoding/json"
@@ -23,9 +23,9 @@
 }
 
 // LoginBasic does basic user authentication
-func (g *Client) LoginBasic(username, password string, scopes []string) error {
-	if g == nil {
-		return fmt.Errorf("use of uninitialized gondole client")
+func (mc *Client) LoginBasic(username, password string, scopes []string) error {
+	if mc == nil {
+		return ErrUninitializedClient
 	}
 
 	if username == "" {
@@ -38,11 +38,11 @@
 	hdrs := make(map[string]string)
 	opts := make(map[string]string)
 
-	hdrs["User-Agent"] = "Gondole/" + GondoleVersion
+	hdrs["User-Agent"] = "madon/" + MadonVersion
 
 	opts["grant_type"] = "password"
-	opts["client_id"] = g.ID
-	opts["client_secret"] = g.Secret
+	opts["client_id"] = mc.ID
+	opts["client_secret"] = mc.Secret
 	opts["username"] = username
 	opts["password"] = password
 	if len(scopes) > 0 {
@@ -50,7 +50,7 @@
 	}
 
 	req := rest.Request{
-		BaseURL:     g.InstanceURL + "/oauth/token",
+		BaseURL:     mc.InstanceURL + "/oauth/token",
 		Headers:     hdrs,
 		QueryParams: opts,
 		Method:      rest.Post,
@@ -68,18 +68,18 @@
 		return fmt.Errorf("cannot unmarshal server response: %s", err.Error())
 	}
 
-	g.UserToken = &resp
+	mc.UserToken = &resp
 	return nil
 }
 
 // SetUserToken sets an existing user credentials
 // No verification of the arguments is made.
-func (g *Client) SetUserToken(token, username, password string, scopes []string) error {
-	if g == nil {
-		return fmt.Errorf("use of uninitialized gondole client")
+func (mc *Client) SetUserToken(token, username, password string, scopes []string) error {
+	if mc == nil {
+		return ErrUninitializedClient
 	}
 
-	g.UserToken = &UserToken{
+	mc.UserToken = &UserToken{
 		AccessToken: token,
 		Scope:       strings.Join(scopes, " "),
 		TokenType:   "bearer",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/madon.go	Wed Apr 19 10:43:38 2017 +0200
@@ -0,0 +1,36 @@
+/*
+Copyright 2017 Ollivier Robert
+Copyright 2017 Mikael Berthe
+
+Licensed under the MIT license.  Please see the LICENSE file is this directory.
+*/
+
+package madon
+
+import (
+	"errors"
+)
+
+// apiCallParams is a map with the parameters for an API call
+type apiCallParams map[string]string
+
+const (
+	// MadonVersion contains the version of the Madon library
+	MadonVersion = "0.2"
+
+	// API version implemented in this library
+	apiVersion     = "v1"
+	currentAPIPath = "/api/" + apiVersion
+
+	// NoRedirect is the URI for no redirection in the App registration
+	NoRedirect = "urn:ietf:wg:oauth:2.0:oob"
+)
+
+// Error codes
+var (
+	ErrUninitializedClient = errors.New("use of uninitialized madon client")
+	ErrAlreadyRegistered   = errors.New("app already registered")
+	ErrEntityNotFound      = errors.New("entity not found")
+	ErrInvalidParameter    = errors.New("incorrect parameter")
+	ErrInvalidID           = errors.New("incorrect entity ID")
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/madon_test.go	Wed Apr 19 10:43:38 2017 +0200
@@ -0,0 +1,21 @@
+package madon
+
+import (
+	"testing"
+
+	"github.com/sendgrid/rest"
+	"github.com/stretchr/testify/assert"
+)
+
+func TestPrepareRequest(t *testing.T) {
+	mc := &Client{
+		Name:    "foo",
+		ID:      "666",
+		Secret:  "biiiip",
+		APIBase: "http://example.com",
+	}
+
+	req, err := mc.prepareRequest("bar", rest.Get, nil)
+	assert.NoError(t, err, "no error")
+	assert.NotNil(t, req.Headers, "not nil")
+}
--- a/media.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/media.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,7 +4,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"bytes"
@@ -19,7 +19,7 @@
 )
 
 // UploadMedia uploads the given file and returns an attachment
-func (g *Client) UploadMedia(filePath string) (*Attachment, error) {
+func (mc *Client) UploadMedia(filePath string) (*Attachment, error) {
 	var b bytes.Buffer
 
 	if filePath == "" {
@@ -43,7 +43,7 @@
 
 	w.Close()
 
-	req, err := g.prepareRequest("media", rest.Post, nil)
+	req, err := mc.prepareRequest("media", rest.Post, nil)
 	if err != nil {
 		return nil, fmt.Errorf("media prepareRequest failed: %s", err.Error())
 	}
--- a/notifications.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/notifications.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,7 +4,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"strconv"
@@ -13,9 +13,9 @@
 )
 
 // GetNotifications returns the list of the user's notifications
-func (g *Client) GetNotifications() ([]Notification, error) {
+func (mc *Client) GetNotifications() ([]Notification, error) {
 	var notifications []Notification
-	if err := g.apiCall("notifications", rest.Get, nil, &notifications); err != nil {
+	if err := mc.apiCall("notifications", rest.Get, nil, &notifications); err != nil {
 		return nil, err
 	}
 	return notifications, nil
@@ -24,14 +24,14 @@
 // GetNotification returns a notification
 // The returned notification can be nil if there is an error or if the
 // requested notification does not exist.
-func (g *Client) GetNotification(notificationID int) (*Notification, error) {
+func (mc *Client) GetNotification(notificationID int) (*Notification, error) {
 	if notificationID < 1 {
 		return nil, ErrInvalidID
 	}
 
 	var endPoint = "notifications/" + strconv.Itoa(notificationID)
 	var notification Notification
-	if err := g.apiCall(endPoint, rest.Get, nil, &notification); err != nil {
+	if err := mc.apiCall(endPoint, rest.Get, nil, &notification); err != nil {
 		return nil, err
 	}
 	if notification.ID == 0 {
@@ -42,6 +42,6 @@
 
 // ClearNotifications deletes all notifications from the Mastodon server for
 // the authenticated user
-func (g *Client) ClearNotifications() error {
-	return g.apiCall("notifications/clear", rest.Post, nil, &Notification{})
+func (mc *Client) ClearNotifications() error {
+	return mc.apiCall("notifications/clear", rest.Post, nil, &Notification{})
 }
--- a/report.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/report.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,7 +4,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"fmt"
@@ -14,16 +14,16 @@
 )
 
 // GetReports returns the current user's reports
-func (g *Client) GetReports() ([]Report, error) {
+func (mc *Client) GetReports() ([]Report, error) {
 	var reports []Report
-	if err := g.apiCall("reports", rest.Get, nil, &reports); err != nil {
+	if err := mc.apiCall("reports", rest.Get, nil, &reports); err != nil {
 		return nil, err
 	}
 	return reports, nil
 }
 
 // ReportUser reports the user account
-func (g *Client) ReportUser(accountID int, statusIDs []int, comment string) (*Report, error) {
+func (mc *Client) ReportUser(accountID int, statusIDs []int, comment string) (*Report, error) {
 	if accountID < 1 || comment == "" || len(statusIDs) < 1 {
 		return nil, ErrInvalidParameter
 	}
@@ -40,7 +40,7 @@
 	}
 
 	var report Report
-	if err := g.apiCall("reports", rest.Post, params, &report); err != nil {
+	if err := mc.apiCall("reports", rest.Post, params, &report); err != nil {
 		return nil, err
 	}
 	return &report, nil
--- a/report_test.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-package gondole
--- a/search.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/search.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,14 +4,14 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"github.com/sendgrid/rest"
 )
 
 // Search search for contents (accounts or statuses) and returns a Results
-func (g *Client) Search(query string, resolve bool) (*Results, error) {
+func (mc *Client) Search(query string, resolve bool) (*Results, error) {
 	if query == "" {
 		return nil, ErrInvalidParameter
 	}
@@ -23,7 +23,7 @@
 	}
 
 	var results Results
-	if err := g.apiCall("search", rest.Get, params, &results); err != nil {
+	if err := mc.apiCall("search", rest.Get, params, &results); err != nil {
 		return nil, err
 	}
 	return &results, nil
--- a/status.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/status.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,7 +4,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"fmt"
@@ -31,7 +31,7 @@
 // The operation 'op' can be empty or "status" (the status itself), "context",
 // "card", "reblogged_by", "favourited_by".
 // The data argument will receive the object(s) returned by the API server.
-func (g *Client) queryStatusData(statusID int, op string, data interface{}) error {
+func (mc *Client) queryStatusData(statusID int, op string, data interface{}) error {
 	if statusID < 1 {
 		return ErrInvalidID
 	}
@@ -48,14 +48,14 @@
 		endPoint += "/" + op
 	}
 
-	return g.apiCall(endPoint, rest.Get, nil, data)
+	return mc.apiCall(endPoint, rest.Get, nil, data)
 }
 
 // updateStatusData updates the statuses
 // The operation 'op' can be empty or "status" (to post a status), "delete"
 // (for deleting a status), "reblog", "unreblog", "favourite", "unfavourite".
 // The data argument will receive the object(s) returned by the API server.
-func (g *Client) updateStatusData(op string, opts updateStatusOptions, data interface{}) error {
+func (mc *Client) updateStatusData(op string, opts updateStatusOptions, data interface{}) error {
 	method := rest.Post
 	endPoint := "statuses"
 	params := make(apiCallParams)
@@ -114,16 +114,16 @@
 		}
 	}
 
-	return g.apiCall(endPoint, method, params, data)
+	return mc.apiCall(endPoint, method, params, data)
 }
 
 // GetStatus returns a status
 // The returned status can be nil if there is an error or if the
 // requested ID does not exist.
-func (g *Client) GetStatus(statusID int) (*Status, error) {
+func (mc *Client) GetStatus(statusID int) (*Status, error) {
 	var status Status
 
-	if err := g.queryStatusData(statusID, "status", &status); err != nil {
+	if err := mc.queryStatusData(statusID, "status", &status); err != nil {
 		return nil, err
 	}
 	if status.ID == 0 {
@@ -133,41 +133,41 @@
 }
 
 // GetStatusContext returns a status context
-func (g *Client) GetStatusContext(statusID int) (*Context, error) {
+func (mc *Client) GetStatusContext(statusID int) (*Context, error) {
 	var context Context
-	if err := g.queryStatusData(statusID, "context", &context); err != nil {
+	if err := mc.queryStatusData(statusID, "context", &context); err != nil {
 		return nil, err
 	}
 	return &context, nil
 }
 
 // GetStatusCard returns a status card
-func (g *Client) GetStatusCard(statusID int) (*Card, error) {
+func (mc *Client) GetStatusCard(statusID int) (*Card, error) {
 	var card Card
-	if err := g.queryStatusData(statusID, "card", &card); err != nil {
+	if err := mc.queryStatusData(statusID, "card", &card); err != nil {
 		return nil, err
 	}
 	return &card, nil
 }
 
 // GetStatusRebloggedBy returns a list of the accounts who reblogged a status
-func (g *Client) GetStatusRebloggedBy(statusID int) ([]Account, error) {
+func (mc *Client) GetStatusRebloggedBy(statusID int) ([]Account, error) {
 	var accounts []Account
-	err := g.queryStatusData(statusID, "reblogged_by", &accounts)
+	err := mc.queryStatusData(statusID, "reblogged_by", &accounts)
 	return accounts, err
 }
 
 // GetStatusFavouritedBy returns a list of the accounts who favourited a status
-func (g *Client) GetStatusFavouritedBy(statusID int) ([]Account, error) {
+func (mc *Client) GetStatusFavouritedBy(statusID int) ([]Account, error) {
 	var accounts []Account
-	err := g.queryStatusData(statusID, "favourited_by", &accounts)
+	err := mc.queryStatusData(statusID, "favourited_by", &accounts)
 	return accounts, err
 }
 
 // PostStatus posts a new "toot"
 // All parameters but "text" can be empty.
 // Visibility must be empty, or one of "direct", "private", "unlisted" and "public".
-func (g *Client) PostStatus(text string, inReplyTo int, mediaIDs []int, sensitive bool, spoilerText string, visibility string) (*Status, error) {
+func (mc *Client) PostStatus(text string, inReplyTo int, mediaIDs []int, sensitive bool, spoilerText string, visibility string) (*Status, error) {
 	var status Status
 	o := updateStatusOptions{
 		Status:      text,
@@ -178,7 +178,7 @@
 		Visibility:  visibility,
 	}
 
-	err := g.updateStatusData("status", o, &status)
+	err := mc.updateStatusData("status", o, &status)
 	if err != nil {
 		return nil, err
 	}
@@ -189,41 +189,41 @@
 }
 
 // DeleteStatus deletes a status
-func (g *Client) DeleteStatus(statusID int) error {
+func (mc *Client) DeleteStatus(statusID int) error {
 	var status Status
 	o := updateStatusOptions{ID: statusID}
-	err := g.updateStatusData("delete", o, &status)
+	err := mc.updateStatusData("delete", o, &status)
 	return err
 }
 
 // ReblogStatus reblogs a status
-func (g *Client) ReblogStatus(statusID int) error {
+func (mc *Client) ReblogStatus(statusID int) error {
 	var status Status
 	o := updateStatusOptions{ID: statusID}
-	err := g.updateStatusData("reblog", o, &status)
+	err := mc.updateStatusData("reblog", o, &status)
 	return err
 }
 
 // UnreblogStatus unreblogs a status
-func (g *Client) UnreblogStatus(statusID int) error {
+func (mc *Client) UnreblogStatus(statusID int) error {
 	var status Status
 	o := updateStatusOptions{ID: statusID}
-	err := g.updateStatusData("unreblog", o, &status)
+	err := mc.updateStatusData("unreblog", o, &status)
 	return err
 }
 
 // FavouriteStatus favourites a status
-func (g *Client) FavouriteStatus(statusID int) error {
+func (mc *Client) FavouriteStatus(statusID int) error {
 	var status Status
 	o := updateStatusOptions{ID: statusID}
-	err := g.updateStatusData("favourite", o, &status)
+	err := mc.updateStatusData("favourite", o, &status)
 	return err
 }
 
 // UnfavouriteStatus unfavourites a status
-func (g *Client) UnfavouriteStatus(statusID int) error {
+func (mc *Client) UnfavouriteStatus(statusID int) error {
 	var status Status
 	o := updateStatusOptions{ID: statusID}
-	err := g.updateStatusData("unfavourite", o, &status)
+	err := mc.updateStatusData("unfavourite", o, &status)
 	return err
 }
--- a/status_test.go	Wed Apr 19 09:30:47 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-package gondole
--- a/streams.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/streams.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,7 +4,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"bufio"
@@ -33,7 +33,7 @@
 // the stream.
 // The stream name can be "user", "public" or "hashtag".
 // For "hashtag", the hashTag argument cannot be empty.
-func (g *Client) openStream(streamName, hashTag string) (*http.Response, error) {
+func (mc *Client) openStream(streamName, hashTag string) (*http.Response, error) {
 	params := make(apiCallParams)
 
 	switch streamName {
@@ -47,7 +47,7 @@
 		return nil, ErrInvalidParameter
 	}
 
-	req, err := g.prepareRequest("streaming/"+streamName, rest.Get, params)
+	req, err := mc.prepareRequest("streaming/"+streamName, rest.Get, params)
 	if err != nil {
 		return nil, fmt.Errorf("cannot build stream request: %s", err.Error())
 	}
@@ -71,7 +71,7 @@
 // readStream reads from the http.Response and sends events to the events channel
 // It stops when the connection is closed or when the stopCh channel is closed.
 // The foroutine will close the doneCh channel when it terminates.
-func (g *Client) readStream(events chan<- StreamEvent, stopCh <-chan bool, doneCh chan<- bool, r *http.Response) {
+func (mc *Client) readStream(events chan<- StreamEvent, stopCh <-chan bool, doneCh chan<- bool, r *http.Response) {
 	defer r.Body.Close()
 
 	reader := bufio.NewReader(r.Body)
@@ -184,15 +184,15 @@
 // The streaming is terminated if the 'stopCh' channel is closed.
 // The 'doneCh' channel is closed if the connection is closed by the server.
 // Please note that this method launches a goroutine to listen to the events.
-func (g *Client) StreamListener(name, hashTag string, events chan<- StreamEvent, stopCh <-chan bool, doneCh chan<- bool) error {
-	if g == nil {
-		return fmt.Errorf("use of uninitialized gondole client")
+func (mc *Client) StreamListener(name, hashTag string, events chan<- StreamEvent, stopCh <-chan bool, doneCh chan<- bool) error {
+	if mc == nil {
+		return ErrUninitializedClient
 	}
 
-	resp, err := g.openStream(name, hashTag)
+	resp, err := mc.openStream(name, hashTag)
 	if err != nil {
 		return err
 	}
-	go g.readStream(events, stopCh, doneCh, resp)
+	go mc.readStream(events, stopCh, doneCh, resp)
 	return nil
 }
--- a/timelines.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/timelines.go	Wed Apr 19 10:43:38 2017 +0200
@@ -4,7 +4,7 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"fmt"
@@ -17,7 +17,7 @@
 // timeline can be "home", "public", or a hashtag (use ":hashtag" or "#hashtag")
 // For the public timelines, you can set 'local' to true to get only the
 // local instance.
-func (g *Client) GetTimelines(timeline string, local bool) ([]Status, error) {
+func (mc *Client) GetTimelines(timeline string, local bool) ([]Status, error) {
 	var endPoint string
 
 	switch {
@@ -39,7 +39,7 @@
 	}
 
 	var tl []Status
-	if err := g.apiCall(endPoint, rest.Get, params, &tl); err != nil {
+	if err := mc.apiCall(endPoint, rest.Get, params, &tl); err != nil {
 		return nil, err
 	}
 	return tl, nil
--- a/types.go	Wed Apr 19 09:30:47 2017 +0200
+++ b/types.go	Wed Apr 19 10:43:38 2017 +0200
@@ -5,13 +5,13 @@
 Licensed under the MIT license.  Please see the LICENSE file is this directory.
 */
 
-package gondole
+package madon
 
 import (
 	"time"
 )
 
-// Client contains data for a gondole client application
+// Client contains data for a madon client application
 type Client struct {
 	Name        string // Name of the client
 	ID          string // Application ID
@@ -23,9 +23,7 @@
 }
 
 /*
-Entities:
-
-Everything manipulated/returned by the API
+Entities - Everything manipulated/returned by the API
 */
 
 // Account represents a Mastodon account entity