Skip to content

Commit

Permalink
only show flags with single dash
Browse files Browse the repository at this point in the history
  • Loading branch information
nanjiangshu committed Jan 15, 2025
1 parent 0546632 commit 30d1c4f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
42 changes: 21 additions & 21 deletions download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ datasets being downloaded.
Important:
Provide exactly one of the following options to specify files to download:
- [filepath(s) or fileid(s)]
- --dataset
- --recursive <dirpath>
- --from-file <list-filepath>
- -dataset
- -recursive <dirpath>
- -from-file <list-filepath>
Global options:
-config CONFIGFILE Path to the configuration file.
Required options:
-dataset-id <datasetID> Dataset ID for the file(s) to download.
-url <uri> The url of the download server.
-dataset-id <datasetID> Dataset ID for the file(s) to download.
-url <uri> The url of the download server.
Optional options:
--pubkey <public-key-file> Encrypt downloaded files server-side using the specified public key.
-outdir <dir> Directory to save the downloaded files.
If not specified, files will be saved in the current directory.
--dataset Download all files in the dataset specified by '-dataset-id'.
--recursive <dirpath> Download all files recursively from the given directory path.
--from-file <list-filepath> Download all files listed in the specified file.
-pubkey <public-key-file> Encrypt downloaded files server-side using the specified public key.
-outdir <dir> Directory to save the downloaded files.
If not specified, files will be saved in the current directory.
-dataset Download all files in the dataset specified by '-dataset-id'.
-recursive <dirpath> Download all files recursively from the given directory path.
-from-file <list-filepath> Download all files listed in the specified file.
Arguments:
[filepath(s)] Specific file paths to download.
Expand Down Expand Up @@ -109,12 +109,12 @@ func Download(args []string, configPath string) error {
return fmt.Errorf("missing required arguments, dataset, config and url are required")
}

// Check if both --recursive and --dataset flags are set
// Check if both -recursive and -dataset flags are set
if *recursiveDownload && *datasetdownload {
return fmt.Errorf("both --recursive and --dataset flags are set, choose one of them")
return fmt.Errorf("both -recursive and -dataset flags are set, choose one of them")
}

// Check that file(s) are not missing if the --dataset flag is not set
// Check that file(s) are not missing if the -dataset flag is not set
if len(Args.Args()) == 0 && !*datasetdownload {
if !*recursiveDownload {
return fmt.Errorf("no files provided for download")
Expand All @@ -123,17 +123,17 @@ func Download(args []string, configPath string) error {
return fmt.Errorf("no folders provided for recursive download")
}

// Check if --dataset flag is set and files are provided
// Check if -dataset flag is set and files are provided
if *datasetdownload && len(Args.Args()) > 0 {
return fmt.Errorf(
"files provided with --dataset flag, add either the flag or the file(s), not both",
"files provided with -dataset flag, add either the flag or the file(s), not both",
)
}

// Check if --from-file flag is set and only one file is provided
// Check if -from-file flag is set and only one file is provided
if *fromFile && len(Args.Args()) != 1 {
return fmt.Errorf(
"one file should be provided with --from-file flag",
"one file should be provided with -from-file flag",
)
}

Expand All @@ -150,11 +150,11 @@ func Download(args []string, configPath string) error {
}

switch {
// Case where the user is setting the --dataset flag
// Case where the user is setting the -dataset flag
// then download all the files in the dataset.
// Case where the user is setting the --recursive flag
// Case where the user is setting the -recursive flag
// then download the content of the path
// Case where the user is setting the --from-file flag
// Case where the user is setting the -from-file flag
// then download the files from the file list
// Default case, download the provided files.
case *datasetdownload:
Expand Down
4 changes: 2 additions & 2 deletions htsget/htsget.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Optional options:
-output <file> Output name for the downloaded file.
If not specified, the file will be downloaded to the current directory
as the original filename.
--force-overwrite Overwrite existing files without prompting.`
-force-overwrite Overwrite existing files without prompting.`

// Args is a flagset that needs to be exported so that it can be written to the
// main program help
Expand Down Expand Up @@ -169,7 +169,7 @@ func downloadFiles(htsgeURLs htsgetResponse, config *helpers.Config) (err error)
}

if helpers.FileExists(filenameToUse) && !*forceOverwrite {
return fmt.Errorf("local file already exists, use --force-overwrite to overwrite")
return fmt.Errorf("local file already exists, use -force-overwrite to overwrite")
}
out, err := os.OpenFile(filenameToUse, os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
Expand Down

0 comments on commit 30d1c4f

Please sign in to comment.