Skip to content
Snippets Groups Projects
Commit b062f015 authored by ale's avatar ale
Browse files

Make some things private

parent 4d07f9a7
No related branches found
No related tags found
1 merge request!1v2.0
......@@ -117,22 +117,22 @@ func (v *floatOptionalValue) Get() interface{} {
return v.value
}
type HasAddFlags interface {
type hasAddFlags interface {
AddFlags(*gonutsflag.FlagSet)
}
type CommandInterface interface {
type commandInterface interface {
Run([]string)
Command() *commander.Command
}
type BaseCommand struct {
type baseCommand struct {
UsageLine string
Short string
Long string
}
func (b *BaseCommand) Command() *commander.Command {
func (b *baseCommand) Command() *commander.Command {
return &commander.Command{
UsageLine: b.UsageLine,
Short: b.Short,
......@@ -140,7 +140,7 @@ func (b *BaseCommand) Command() *commander.Command {
}
}
func (b *BaseCommand) Run(args []string) {
func (b *baseCommand) Run(args []string) {
}
var auClient *client.Client
......@@ -159,14 +159,14 @@ func getClient() *client.Client {
return auClient
}
func setRelay(m *pb.Mount, relayUrl string) {
if relayUrl == "" {
func setRelay(m *pb.Mount, relayURL string) {
if relayURL == "" {
// Randomly generate source credentials.
m.SourceUsername = autoradio.GenerateUsername(m.Path)
m.SourcePassword = autoradio.GeneratePassword()
} else {
// Validate the given relay URL.
u, err := url.Parse(relayUrl)
u, err := url.Parse(relayURL)
if err != nil {
log.Fatal(err)
}
......@@ -213,14 +213,14 @@ func mountExists(name string, c *client.Client) bool {
// Create a new mountpoint.
type createMountCommand struct {
BaseCommand
baseCommand
relay string
fallback string
}
func newCreateMountCommand() *createMountCommand {
return &createMountCommand{
BaseCommand: BaseCommand{
baseCommand: baseCommand{
UsageLine: "create-mount <path>",
Short: "Create a new mountpoint",
Long: `
......@@ -273,7 +273,7 @@ func (cmd *createMountCommand) Run(args []string) {
// Create a submount (transcoded stream).
type createTranscodingMountCommand struct {
BaseCommand
baseCommand
sourcePath string
format string
......@@ -287,7 +287,7 @@ type createTranscodingMountCommand struct {
func newCreateTranscodingMountCommand() *createTranscodingMountCommand {
return &createTranscodingMountCommand{
BaseCommand: BaseCommand{
baseCommand: baseCommand{
UsageLine: "create-transcoding-mount <path>",
Short: "Create a transcoding mount",
Long: `
......@@ -302,7 +302,7 @@ func (cmd *createTranscodingMountCommand) AddFlags(f *gonutsflag.FlagSet) {
f.StringVar(&cmd.sourcePath, "source", "", "Source mountpoint")
f.StringVar(&cmd.format, "codec", "mp3", "Encoding format")
f.Float64Var(&cmd.quality, "quality", 0, "Quality (for VBR encoders)")
f.IntVar(&cmd.bitRate, "bitrate", 32, "Bitrate (kbps)")
f.IntVar(&cmd.bitRate, "bitrate", 32, "Bitrate (Kbps)")
f.IntVar(&cmd.sampleRate, "samplerate", 44100, "Sample rate (Hz)")
f.IntVar(&cmd.channels, "channels", 2, "Number of channels")
f.StringVar(&cmd.stereoMode, "stereo-mode", "joint_stereo", "Stereo mode for mp3 codec (stereo, joint_stereo)")
......@@ -360,7 +360,7 @@ func (cmd *createTranscodingMountCommand) Run(args []string) {
// Edit a mountpoint.
type editMountCommand struct {
BaseCommand
baseCommand
relay *stringOptionalValue
fallback *stringOptionalValue
transFormat *stringOptionalValue
......@@ -376,7 +376,7 @@ var UNSET = "UNSET"
func newEditMountCommand() *editMountCommand {
return &editMountCommand{
BaseCommand: BaseCommand{
baseCommand: baseCommand{
UsageLine: "edit-mount <path>",
Short: "Edit an existing mountpoint",
Long: `
......@@ -406,7 +406,7 @@ func (cmd *editMountCommand) AddFlags(f *gonutsflag.FlagSet) {
f.Var(cmd.transSource, "source", "[transcoding] Source mountpoint")
f.Var(cmd.transFormat, "codec", "[transcoding] Encoding format")
f.Var(cmd.transQuality, "quality", "[transcoding] Quality (for VBR encoders)")
f.Var(cmd.transBitRate, "bitrate", "[transcoding] Bitrate (kbps)")
f.Var(cmd.transBitRate, "bitrate", "[transcoding] Bitrate (Kbps)")
f.Var(cmd.transSampleRate, "samplerate", "[transcoding] Sample rate (Hz)")
f.Var(cmd.transChannels, "channels", "[transcoding] Number of channels")
f.Var(cmd.transStereoMode, "stereo-mode", "[transcoding] Stereo mode for mp3 encoding (stereo, joint_stereo)")
......@@ -489,12 +489,12 @@ func (cmd *editMountCommand) Run(args []string) {
// Delete an existing mountpoint.
type deleteMountCommand struct {
BaseCommand
baseCommand
}
func newDeleteMountCommand() *deleteMountCommand {
return &deleteMountCommand{
BaseCommand{
baseCommand{
UsageLine: "delete-mount <path>",
Short: "Delete a mountpoint",
Long: `
......@@ -537,12 +537,12 @@ func (cmd *deleteMountCommand) Run(args []string) {
// List known mountpoints.
type listMountsCommand struct {
BaseCommand
baseCommand
}
func newListMountsCommand() *listMountsCommand {
return &listMountsCommand{
BaseCommand{
baseCommand{
UsageLine: "list-mounts",
Short: "List all configured mountpoints",
Long: `
......@@ -581,12 +581,12 @@ func (cmd *listMountsCommand) Run(args []string) {
// Show mountpoint information.
type showMountCommand struct {
BaseCommand
baseCommand
}
func newShowMountCommand() *showMountCommand {
return &showMountCommand{
BaseCommand{
baseCommand{
UsageLine: "show-mount <path>",
Short: "Show mountpoint information",
Long: `
......@@ -615,12 +615,12 @@ func (cmd *showMountCommand) Run(args []string) {
// Backup mount configuration.
type backupCommand struct {
BaseCommand
baseCommand
}
func newBackupCommand() *backupCommand {
return &backupCommand{
BaseCommand{
baseCommand{
UsageLine: "backup",
Short: "Backup mount configuration",
Long: `
......@@ -647,12 +647,12 @@ func (cmd *backupCommand) Run(args []string) {
// Restore mount configuration.
type restoreCommand struct {
BaseCommand
baseCommand
}
func newRestoreCommand() *restoreCommand {
return &restoreCommand{
BaseCommand{
baseCommand{
UsageLine: "restore",
Short: "Restore mount configuration",
Long: `
......@@ -685,13 +685,13 @@ var cmdr = &commander.Command{
Short: "Manage `autoradio' configuration",
}
func addCommand(c CommandInterface) {
func addCommand(c commandInterface) {
cmd := c.Command()
cmd.Run = func(unused *commander.Command, args []string) error {
c.Run(args)
return nil
}
if afc, ok := c.(HasAddFlags); ok {
if afc, ok := c.(hasAddFlags); ok {
afc.AddFlags(&cmd.Flag)
}
cmdr.Subcommands = append(cmdr.Subcommands, cmd)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment