func main() { t0 := time.Now() conf := config.Config{} conf.MusicDir = flag.String("music-dir", "/music", "Music dir") conf.Port = flag.Int("port", 8080, "Pickup port") conf.MpdAddress = flag.String("mpd-address", "localhost:6600", "MPD address") conf.MpdPassword = flag.String("mpd-password", "", "MPD Password") flag.Parse(true) log.Printf("Mpd address: '%s' password: '******'\n", *conf.MpdAddress, *conf.MpdPassword) plyr, err := player.NewMpdPlayer(&conf) if err != nil { log.Fatalln("Failed to initialize mpd player", err) } music, err := plyr.GetCollection() if err != nil { log.Fatalln("Failed to retrieve collection", err) } log.Printf("Player with %d categories initialized in %v\n", len(music.Categories), time.Since(t0)) serve(&conf, &plyr) }
func main() { var action = flag.String("action", "serve", "Action to perform (serve|refresh)") conf := config.Config{} conf.MusicDir = flag.String("music-dir", "/music", "Music dir") conf.Port = flag.Int("port", 8080, "Pickup port") conf.MpdAddress = flag.String("mpd-address", "localhost:6600", "MPD address") conf.MpdPassword = flag.String("mpd-password", "", "MPD Password") var query = flag.String("query", "", "Search query") flag.Parse(true) fmt.Println("Action is:", *action) fmt.Printf("Mpd address: '%s' password: '******'\n", *conf.MpdAddress, *conf.MpdPassword) //collection := loadOrRefresh(*conf.MusicDir) music, err := model.RefreshMpd(&conf) if err != nil { log.Fatalf("Couldn't get files from mpd: \n%s\n", err) } switch *action { case "stats": stats(music.Categories[0]) case "search": search(music, *query) case "serve": serve(&conf, music) case "test-playback": testPlayback(&conf, music) case "refresh": os.Exit(0) default: fmt.Println("Unknown action", *action) } }
package tsuru import ( "encoding/json" "fmt" "github.com/globocom/tsuru/cmd" "io" "io/ioutil" "launchpad.net/gnuflag" "net/http" "strings" ) var AppName = gnuflag.String("app", "", "App name for running app related commands.") var LogLines = gnuflag.Int("lines", 10, "The number of log lines to display") var LogSource = gnuflag.String("source", "", "The log from the given source") type AppInfo struct { GuessingCommand } func (c *AppInfo) Info() *cmd.Info { return &cmd.Info{ Name: "app-info", Usage: "app-info [--app appname]", Desc: `show information about your app. If you don't provide the app name, tsuru will try to guess it.`, MinArgs: 0, }