Skip to content

Commit e5f0a6c

Browse files
author
JojiiOfficial
committed
add exclude files
1 parent 0ab1908 commit e5f0a6c

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

Command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func runCommand(parsed string, commandData *commands.CommandData) {
127127
// Download files in namespace
128128
case namespaceDownloadCmd.FullCommand():
129129
commandData.FileAttributes.Namespace = *namespaceDownloadNs
130-
commandData.DownloadNamespace(*namespaceDownloadExcludeGroups, *namespaceDownloadExcludeTags, *namespaceDownloadParallelism, *namespaceDownloadOutputDir)
130+
commandData.DownloadNamespace(*namespaceDownloadExcludeGroups, *namespaceDownloadExcludeTags, *namespaceDownloadExcludeFiles, *namespaceDownloadParallelism, *namespaceDownloadOutputDir)
131131

132132
// -- Ping command
133133
case appPing.FullCommand():

commands/Namespace.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package commands
22

33
import (
4+
"bufio"
45
"fmt"
6+
"os"
57
"sort"
8+
"strconv"
69

710
"github.com/DataManager-Go/libdatamanager"
11+
"github.com/JojiiOfficial/gaw"
812
"github.com/fatih/color"
913
)
1014

@@ -38,6 +42,12 @@ func UpdateNamespace(cData *CommandData, name, newName string, customNS bool) {
3842

3943
// DeleteNamespace update a namespace
4044
func DeleteNamespace(cData *CommandData, name string) {
45+
if !cData.Yes {
46+
if y, _ := gaw.ConfirmInput("Do you really want to delete this namespace [yn]> ", bufio.NewReader(os.Stdin)); !y {
47+
return
48+
}
49+
}
50+
4151
deleteResponse, err := cData.LibDM.DeleteNamespace(name)
4252
if err != nil {
4353
printResponseError(err, "deleting namespace")
@@ -67,8 +77,8 @@ func ListNamespace(cData *CommandData) {
6777
}
6878

6979
// DownloadNamespace download files from namespace
70-
func (cData *CommandData) DownloadNamespace(exGroups, exTags []string, parallelism uint, outDir string) {
71-
ProcesStrSliceParams(&exTags, &exGroups)
80+
func (cData *CommandData) DownloadNamespace(exGroups, exTags, exFiles []string, parallelism uint, outDir string) {
81+
ProcesStrSliceParams(&exTags, &exGroups, &exFiles)
7282

7383
// Get files in namespace from server
7484
files, err := cData.LibDM.ListFiles("", 0, false, libdatamanager.FileAttributes{
@@ -86,12 +96,19 @@ func (cData *CommandData) DownloadNamespace(exGroups, exTags []string, paralleli
8696
// Filter files by tags and groups
8797
a:
8898
for i := range files.Files {
99+
// Exclude FileID
100+
if gaw.IsInStringArray(strconv.FormatUint(uint64(files.Files[i].ID), 10), exFiles) {
101+
continue
102+
}
103+
104+
// Exclude Groups
89105
for j := range exGroups {
90106
if fileHasGroup(&files.Files[i], exGroups[j]) {
91107
continue a
92108
}
93109
}
94110

111+
// Exclude Tags
95112
for j := range exTags {
96113
if fileHasTag(&files.Files[i], exTags[j]) {
97114
continue a

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,13 @@ var (
229229
// -- List
230230
namespaceListCmd = namespaceCmd.Command("list", "List your namespaces").Alias("ls")
231231
// -- Download
232-
namespaceDownloadCmd = namespaceCmd.Command("download", "Download all files in a namespace")
232+
namespaceDownloadCmd = namespaceCmd.Command("download", "Download all files in a namespace").Alias("dl")
233233
namespaceDownloadNs = namespaceDownloadCmd.Arg("namespace", "The namespace to download the files from").HintAction(hintListNamespaces).Required().String()
234234
namespaceDownloadExcludeGroups = namespaceDownloadCmd.Flag("exclude-groups", "Exclude files in specified group(s) from getting downloaded").Strings()
235235
namespaceDownloadExcludeTags = namespaceDownloadCmd.Flag("exclude-tags", "Exclude files having specified tags(s) from getting downloaded").Strings()
236+
namespaceDownloadExcludeFiles = namespaceDownloadCmd.Flag("exclude-files", "Exclude files by ID").Strings()
236237
namespaceDownloadParallelism = namespaceDownloadCmd.Flag("parallelism", "Download multiple files at the same time").Default("1").Uint()
237-
namespaceDownloadOutputDir = namespaceDownloadCmd.Flag("output", "Save namespace in a custom directory than the namespacename").Default("./").String()
238+
namespaceDownloadOutputDir = namespaceDownloadCmd.Flag("output", "Save namespace in a custom directory than the namespacename").Short('o').Default("./").String()
238239

239240
//
240241
// ---------> Keystore commands --------------------------------------

0 commit comments

Comments
 (0)