cmd/streamdata: init sub-command
This initialises a new channel's on-disk representation. Signed-off-by: Yonah <contrib@gensokyo.uk>
This commit is contained in:
@@ -44,6 +44,44 @@ func main() {
|
|||||||
"Channel directory to open",
|
"Channel directory to open",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
c.NewCommand(
|
||||||
|
"init",
|
||||||
|
"Create an empty channel",
|
||||||
|
func(args []string) (err error) {
|
||||||
|
if channel != nil {
|
||||||
|
if err = channel.Close(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
channel = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var pathname string
|
||||||
|
switch len(args) {
|
||||||
|
case 0:
|
||||||
|
pathname = "."
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
pathname = args[0]
|
||||||
|
|
||||||
|
default:
|
||||||
|
return errors.New("init requires 1 argument")
|
||||||
|
}
|
||||||
|
|
||||||
|
defer toErr(&err)
|
||||||
|
isattyStd()
|
||||||
|
br := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
|
var v streamdata.Channel
|
||||||
|
v.Identifier = require(promptUint(br, "Identifier: "))
|
||||||
|
v.Name = require(prompt(br, "Channel name: "))
|
||||||
|
if err = v.Create(pathname); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
channel = &v
|
||||||
|
return
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
c.NewCommand(
|
c.NewCommand(
|
||||||
"add",
|
"add",
|
||||||
"Add a VOD to the channel",
|
"Add a VOD to the channel",
|
||||||
|
|||||||
Reference in New Issue
Block a user