making cli more robust

This commit is contained in:
Saxon1 2018-04-19 19:07:25 +09:30
parent bb4c80ccef
commit e0c1667fcc
1 changed files with 21 additions and 0 deletions

View File

@ -137,11 +137,17 @@ func main() {
config.Input = revid.Rtp config.Input = revid.Rtp
case "File": case "File":
config.Input = revid.File config.Input = revid.File
case "":
default:
fmt.Println("Bad input argument!")
} }
switch *configFlags[inputCodecPtr] { switch *configFlags[inputCodecPtr] {
case "H264Codec": case "H264Codec":
config.InputCodec = revid.H264Codec config.InputCodec = revid.H264Codec
case "":
default:
fmt.Println("Bad input codec argument!")
} }
switch *configFlags[outputPtr] { switch *configFlags[outputPtr] {
@ -151,6 +157,9 @@ func main() {
config.Output = revid.Http config.Output = revid.Http
case "Rtmp": case "Rtmp":
config.Output = revid.Rtmp config.Output = revid.Rtmp
case "":
default:
fmt.Println("Bad output argument!")
} }
switch *configFlags[rtmpMethodPtr] { switch *configFlags[rtmpMethodPtr] {
@ -158,6 +167,9 @@ func main() {
config.RtmpMethod = revid.Ffmpeg config.RtmpMethod = revid.Ffmpeg
case "LibRtmp": case "LibRtmp":
config.RtmpMethod = revid.LibRtmp config.RtmpMethod = revid.LibRtmp
case "":
default:
fmt.Println("Bad rtmp method argument!")
} }
switch *configFlags[packetizationPtr] { switch *configFlags[packetizationPtr] {
@ -167,6 +179,9 @@ func main() {
config.Packetization = revid.Rtp config.Packetization = revid.Rtp
case "Flv": case "Flv":
config.Packetization = revid.Flv config.Packetization = revid.Flv
case "":
default:
fmt.Println("Bad packetization argument!")
} }
switch *configFlags[quantizationModePtr] { switch *configFlags[quantizationModePtr] {
@ -174,6 +189,9 @@ func main() {
config.QuantizationMode = revid.QuantizationOn config.QuantizationMode = revid.QuantizationOn
case "QuantizationOff": case "QuantizationOff":
config.QuantizationMode = revid.QuantizationOff config.QuantizationMode = revid.QuantizationOff
case "":
default:
fmt.Println("Bad quantization mode argument!")
} }
switch *configFlags[verbosityPtr] { switch *configFlags[verbosityPtr] {
@ -181,6 +199,9 @@ func main() {
config.Verbosity = revid.No config.Verbosity = revid.No
case "Yes": case "Yes":
config.Verbosity = revid.Yes config.Verbosity = revid.Yes
case "":
default:
fmt.Println("Bad verbosity argument!")
} }
config.FramesPerClip = *configFlags[framesPerClipPtr] config.FramesPerClip = *configFlags[framesPerClipPtr]