refactor: Move drive and recovery commands to subcommands
This commit is contained in:
@@ -208,7 +208,7 @@ func archive(
|
||||
func init() {
|
||||
archiveCmd.PersistentFlags().IntP(recordSizeFlag, "e", 20, "Amount of 512-bit blocks per record")
|
||||
archiveCmd.PersistentFlags().StringP(srcFlag, "s", ".", "File or directory to archive")
|
||||
archiveCmd.PersistentFlags().BoolP(overwriteFlag, "o", false, "Start writing from the start instead of from the end of the tape/file")
|
||||
archiveCmd.PersistentFlags().BoolP(overwriteFlag, "o", false, "Start writing from the start instead of from the end of the tape or tar file")
|
||||
|
||||
viper.AutomaticEnv()
|
||||
|
||||
|
||||
@@ -35,5 +35,5 @@ var ejectCmd = &cobra.Command{
|
||||
func init() {
|
||||
viper.AutomaticEnv()
|
||||
|
||||
rootCmd.AddCommand(ejectCmd)
|
||||
driveCmd.AddCommand(ejectCmd)
|
||||
}
|
||||
17
cmd/stbak/cmd/drive_root.go
Normal file
17
cmd/stbak/cmd/drive_root.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var driveCmd = &cobra.Command{
|
||||
Use: "drive",
|
||||
Short: "Manage tape drives",
|
||||
}
|
||||
|
||||
func init() {
|
||||
viper.AutomaticEnv()
|
||||
|
||||
rootCmd.AddCommand(driveCmd)
|
||||
}
|
||||
@@ -43,5 +43,5 @@ var tellCmd = &cobra.Command{
|
||||
func init() {
|
||||
viper.AutomaticEnv()
|
||||
|
||||
rootCmd.AddCommand(tellCmd)
|
||||
driveCmd.AddCommand(tellCmd)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ var moveCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
// Append move headers to the tape/tar file
|
||||
// Append move headers to the tape or tar file
|
||||
for _, dbhdr := range headersToMove {
|
||||
hdr, err := converters.DBHeaderToTarHeader(dbhdr)
|
||||
if err != nil {
|
||||
|
||||
@@ -219,11 +219,11 @@ func init() {
|
||||
indexCmd.PersistentFlags().IntP(recordSizeFlag, "e", 20, "Amount of 512-bit blocks per record")
|
||||
indexCmd.PersistentFlags().IntP(recordFlag, "r", 0, "Record to seek too before counting")
|
||||
indexCmd.PersistentFlags().IntP(blockFlag, "b", 0, "Block in record to seek too before counting")
|
||||
indexCmd.PersistentFlags().BoolP(overwriteFlag, "o", false, "Start writing from the current position instead of from the end of the tape/file")
|
||||
indexCmd.PersistentFlags().BoolP(overwriteFlag, "o", false, "Remove the old index before starting to index")
|
||||
|
||||
viper.AutomaticEnv()
|
||||
|
||||
rootCmd.AddCommand(indexCmd)
|
||||
recoveryCmd.AddCommand(indexCmd)
|
||||
}
|
||||
|
||||
func indexHeader(record, block int64, hdr *tar.Header, metadataPersister *persisters.MetadataPersister) error {
|
||||
@@ -190,5 +190,5 @@ func init() {
|
||||
|
||||
viper.AutomaticEnv()
|
||||
|
||||
rootCmd.AddCommand(listCmd)
|
||||
recoveryCmd.AddCommand(listCmd)
|
||||
}
|
||||
@@ -113,5 +113,5 @@ func init() {
|
||||
|
||||
viper.AutomaticEnv()
|
||||
|
||||
rootCmd.AddCommand(restoreCmd)
|
||||
recoveryCmd.AddCommand(restoreCmd)
|
||||
}
|
||||
17
cmd/stbak/cmd/recovery_root.go
Normal file
17
cmd/stbak/cmd/recovery_root.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var recoveryCmd = &cobra.Command{
|
||||
Use: "recovery",
|
||||
Short: "Recover tapes or tar files",
|
||||
}
|
||||
|
||||
func init() {
|
||||
viper.AutomaticEnv()
|
||||
|
||||
rootCmd.AddCommand(recoveryCmd)
|
||||
}
|
||||
@@ -73,7 +73,7 @@ var removeCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
// Append deletion headers to the tape/tar file
|
||||
// Append deletion headers to the tape or tar file
|
||||
for _, dbhdr := range headersToDelete {
|
||||
hdr, err := converters.DBHeaderToTarHeader(dbhdr)
|
||||
if err != nil {
|
||||
|
||||
@@ -168,7 +168,7 @@ func update(
|
||||
func init() {
|
||||
updateCmd.PersistentFlags().IntP(recordSizeFlag, "e", 20, "Amount of 512-bit blocks per record")
|
||||
updateCmd.PersistentFlags().StringP(srcFlag, "s", "", "Path of the file or directory to update")
|
||||
updateCmd.PersistentFlags().BoolP(contentFlag, "c", false, "Replace the content on the tape/tar file")
|
||||
updateCmd.PersistentFlags().BoolP(contentFlag, "c", false, "Replace the content on the tape or tar file")
|
||||
|
||||
viper.AutomaticEnv()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user