@@ -23,6 +23,8 @@ import (
2323 "math/rand" // for debug purposes
2424)
2525
26+ const VERSION = "0.3"
27+
2628var debugging = false // if true, debug messages will be shown
2729
2830var (
4244 output string
4345 noResume bool
4446 filter string
47+ order string
4548)
4649
4750// progress bar elements
@@ -87,6 +90,7 @@ func Initialize() {
8790 flag .BoolVar (& noResume , "no-resume" , false , "If passed, download starts again, else the download is resumed" )
8891
8992 flag .StringVar (& filter , "filter" , "" , "Filter all pages by some attributes" )
93+ flag .StringVar (& order , "order" , "" , "Order by some attributes" )
9094
9195 flag .Usage = usage
9296 flag .Parse ()
@@ -95,6 +99,7 @@ func Initialize() {
9599 password = strings .TrimSpace (password )
96100 output = strings .TrimSpace (output )
97101 filter = strings .TrimSpace (filter )
102+ order = strings .TrimSpace (order )
98103
99104 // Check for non-valid flags
100105 usernameIsNull := username == ""
@@ -394,18 +399,25 @@ MainLoop:
394399 }
395400}
396401
402+ func version () {
403+ fmt .Fprintln (os .Stderr , "Audisto Data Downloader, Version " + VERSION )
404+ }
405+
397406func usage () {
398- fmt .Fprintf (os .Stderr , `usage: data-downloader [options]
407+ version ()
408+ fmt .Fprintf (os .Stderr , `
409+ usage: data-downloader [options]
399410
400411Parameters:
401412 -username=[USERNAME] API Username (required)
402413 -password=[PASSWORD] API Password (required)
403414 -crawl=[ID] ID of the crawl to download (required)
404415 -output=[FILE] Path for the output file
405416 If missing the data will be send to the terminal (stdout)
406- -no-details If passed, details in API request is set to 0 else
417+ -no-details If passed, details in API request is set to 0 else to 1
407418 -no-resume If passed, download starts again, else the download is resumed
408- -filter=[FILTER] If passed, all pages are filtered by given FILTER
419+ -filter=[FILTER] If passed, all pages are filtered by given FILTER./bui
420+ -order=[ORDER] If passed, all pages are ordered by given ORDER
409421` )
410422}
411423
@@ -533,6 +545,9 @@ func (r *Resumer) nextChunk() ([]byte, int, int64, error) {
533545 if filter != "" {
534546 queryParameters .Add ("filter" , filter )
535547 }
548+ if order != "" {
549+ queryParameters .Add ("order" , order )
550+ }
536551 queryParameters .Add ("chunk" , strconv .FormatInt (nextChunkNumber , 10 ))
537552 queryParameters .Add ("chunk_size" , strconv .FormatInt (r .chunkSize , 10 ))
538553 queryParameters .Add ("output" , "tsv" )
0 commit comments