Skip to content

Commit 3ea84ef

Browse files
authored
Merge pull request #6 from Unpackerr/dn2_manual
updates
2 parents ab4e3f3 + 5371042 commit 3ea84ef

File tree

8 files changed

+99
-44
lines changed

8 files changed

+99
-44
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }}
2323
- name: "Create GPG_SIGNING_KEY file"
2424
run: "echo '${{ secrets.GPG_SIGNING_KEY }}' > /tmp/key.gpg"
25+
- name: "Save Iteration in Revision"
26+
run: "REVISION=(git rev-list --count --all || echo 0) > $GITHUB_ENV"
2527
- uses: actions/setup-go@v5
2628
with:
2729
go-version: stable

.goreleaser.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ builds:
2929
- -X "golift.io/version.Version={{.Version}}"
3030
- -X "golift.io/version.BuildDate={{.Date}}"
3131
- -X "golift.io/version.BuildUser={{.Env.USER}}"
32+
- -X "golift.io/version.Revision={{.Env.REVISION}}"
33+
- -X "golift.io/version.Branch={{.Branch}} ({{.ShortCommit}})"
3234
ignore:
3335
- goos: windows
3436
goarch: arm
@@ -70,7 +72,6 @@ nfpms:
7072
priority: extra
7173
provides:
7274
- xt
73-
# signing
7475
rpm:
7576
signature:
7677
key_file: "{{ .Env.GPG_SIGNING_KEY }}"

MANUAL.md

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ xt(1) -- eXtractor Tool - Recursively decompress archives
44
SYNOPSIS
55
---
66

7-
`xt [options] [path [path] [path] ...]`
7+
`xt [options] [path [path] [path] ...]`
8+
`xt --job-file /tmp/job1 -j /tmp/job2`\
89

910
DESCRIPTION
1011
---
@@ -17,46 +18,55 @@ DESCRIPTION
1718
OPTIONS
1819
---
1920

20-
`xt [-o </path>] [-d <#>] [-m <#>] [-p <p4ss,words>] [paths]`
21+
`xt [-o </dir>] [-d <#>] [-m <#>] [-e <.ext>] [-p <p4ss,words>] [paths]`
2122

22-
-o, --output </path>
23-
Provide a file system path where content should be written.
24-
The default output path is the current working directory.
23+
-o _directory_, --output _directory_
24+
Provide a file system _directory_ where content is written.
25+
The default output _directory_ is the current working directory.
2526

26-
-d, --max-depth <child count>
27-
This option limits how deep into the file system xt recurses.
28-
The default is (0) unlimited. Setting to 1 disables recursion.
27+
-d _count_, --max-depth _count_
28+
This option limits how deep into the file system xt recurses.
29+
The default is (0) unlimited. Setting to 1 disables recursion.
2930

30-
-m, --min-depth <child count>
31-
This option determines if archives should only be found deeper
32-
into the file system. The default is (0) root. Archives are only
33-
extracted from <child count> sub directories deep or deeper.
31+
-m _count_, --min-depth _count_
32+
This option determines if archives should only be found deeper
33+
into the file system. The default is (0) root. Archives are only
34+
extracted from _count_ sub directories deep or deeper.
3435

35-
-P, --password <p4ss word>,<pass w0rd>
36-
Provided password(s) are attempted against extraction of encrypted
37-
rar and/or 7zip archives. The -p option may be provided many times.
36+
-P _password_, --password _password_
37+
Provided _passwords_ are attempted against extraction of encrypted
38+
rar and/or 7zip archives. The `-p` option may be provided many times.
3839

39-
-j, --job-file <job file>
40-
The options above create a single job. If you want more control,
41-
you may provide one or more job files. Each file may define the
42-
input, output, depths and passwords, etc. Acceptable formats are
43-
xml, json, toml and yaml. TOML is the default. See JOB FILES below.
40+
-e _.ext_, --extension _.ext_
41+
Only extract archives with these extensions. Include the leading dot.
42+
The `-e` option may be provided many times.
43+
Use `-v` for supported extensions. <- Your input must match the
44+
supported extensions. Unknown extensions are still ignored.
4445

45-
-v, --version
46-
Display version and exit.
46+
-j _file_, --job-file _file_
47+
The options above create a single job. If you want more control,
48+
you may provide one or more job files. Each _file_ may define the
49+
input, output, depths and passwords, etc. Acceptable formats are
50+
xml, json, toml and yaml. TOML is the default. See JOB FILES below.
4751

48-
-h, --help
49-
Display usage and exit.
52+
-v, --version
53+
Display version and exit.
54+
55+
-h, --help
56+
Display usage and exit.
5057

5158
JOB FILES
5259
---
5360

61+
If `include_suffix` is provided `exclude_suffix` is ignored.
62+
5463
Example TOML job file:
5564

5665
paths = [ '/path1', '/another/path' ]
5766
output = '.'
5867
passwords = [ 'password1', '''password"With'Specials!''', 'pass3']
5968
exclude_suffix = ['.iso', '.gz']
69+
include_suffix = ['.zip', '.rar', '.r00']
6070
max_depth = 0
6171
min_depth = 1
6272
file_mode = 644

go.mod

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,30 @@ go 1.20
55
require (
66
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace
77
golift.io/version v0.0.2
8-
golift.io/xtractr v0.2.3-0.20240130233802-72495ada05e7
8+
golift.io/xtractr v0.2.3-0.20240202194230-2edf9aff9619
9+
)
10+
11+
require (
12+
github.com/cavaliergopher/cpio v1.0.1 // indirect
13+
github.com/cavaliergopher/rpm v1.2.0 // indirect
14+
github.com/peterebden/ar v0.0.0-20230524111245-4f7c7b065694 // indirect
15+
github.com/sshaman1101/dcompress v0.0.0-20200109162717-50436a6332de // indirect
16+
github.com/therootcompany/xz v1.0.1 // indirect
17+
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
918
)
1019

1120
require (
1221
github.com/BurntSushi/toml v1.3.0 // indirect
13-
github.com/andybalholm/brotli v1.0.6 // indirect
22+
github.com/andybalholm/brotli v1.1.0 // indirect
1423
github.com/bodgit/plumbing v1.3.0 // indirect
1524
github.com/bodgit/sevenzip v1.4.5 // indirect
1625
github.com/bodgit/windows v1.0.1 // indirect
1726
github.com/hashicorp/errwrap v1.1.0 // indirect
1827
github.com/hashicorp/go-multierror v1.1.1 // indirect
1928
github.com/kdomanski/iso9660 v0.4.0 // indirect
20-
github.com/klauspost/compress v1.17.4 // indirect
29+
github.com/klauspost/compress v1.17.5 // indirect
2130
github.com/nwaples/rardecode v1.1.3 // indirect
22-
github.com/pierrec/lz4/v4 v4.1.19 // indirect
31+
github.com/pierrec/lz4/v4 v4.1.21 // indirect
2332
github.com/ulikunitz/xz v0.5.11 // indirect
2433
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
2534
golang.org/x/text v0.14.0 // indirect

go.sum

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
1919
github.com/BurntSushi/toml v1.3.0 h1:Ws8e5YmnrGEHzZEzg0YvK/7COGYtTC5PbaH9oSSbgfA=
2020
github.com/BurntSushi/toml v1.3.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
2121
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
22-
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
23-
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
22+
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
23+
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
2424
github.com/bodgit/plumbing v1.3.0 h1:pf9Itz1JOQgn7vEOE7v7nlEfBykYqvUYioC61TwWCFU=
2525
github.com/bodgit/plumbing v1.3.0/go.mod h1:JOTb4XiRu5xfnmdnDJo6GmSbSbtSyufrsyZFByMtKEs=
2626
github.com/bodgit/sevenzip v1.4.5 h1:HFJQ+nbjppfyf2xbQEJBbmVo+o2kTg1FXV4i7YOx87s=
2727
github.com/bodgit/sevenzip v1.4.5/go.mod h1:LAcAg/UQzyjzCQSGBPZFYzoiHMfT6Gk+3tMSjUk3foY=
2828
github.com/bodgit/windows v1.0.1 h1:tF7K6KOluPYygXa3Z2594zxlkbKPAOvqr97etrGNIz4=
2929
github.com/bodgit/windows v1.0.1/go.mod h1:a6JLwrB4KrTR5hBpp8FI9/9W9jJfeQ2h4XDXU74ZCdM=
30+
github.com/cavaliergopher/cpio v1.0.1 h1:KQFSeKmZhv0cr+kawA3a0xTQCU4QxXF1vhU7P7av2KM=
31+
github.com/cavaliergopher/cpio v1.0.1/go.mod h1:pBdaqQjnvXxdS/6CvNDwIANIFSP0xRKI16PX4xejRQc=
32+
github.com/cavaliergopher/rpm v1.2.0 h1:s0h+QeVK252QFTolkhGiMeQ1f+tMeIMhGl8B1HUmGUc=
33+
github.com/cavaliergopher/rpm v1.2.0/go.mod h1:R0q3vTqa7RUvPofAZYrnjJ63hh2vngjFfphuXiExVos=
3034
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
3135
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
3236
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
@@ -77,24 +81,28 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X
7781
github.com/kdomanski/iso9660 v0.4.0 h1:BPKKdcINz3m0MdjIMwS0wx1nofsOjxOq8TOr45WGHFg=
7882
github.com/kdomanski/iso9660 v0.4.0/go.mod h1:OxUSupHsO9ceI8lBLPJKWBTphLemjrCQY8LPXM7qSzU=
7983
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
80-
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
81-
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
84+
github.com/klauspost/compress v1.17.5 h1:d4vBd+7CHydUqpFBgUEKkSdtSugf9YFmSkvUYPquI5E=
85+
github.com/klauspost/compress v1.17.5/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
8286
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
8387
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
8488
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
8589
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
8690
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
8791
github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc=
8892
github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
89-
github.com/pierrec/lz4/v4 v4.1.19 h1:tYLzDnjDXh9qIxSTKHwXwOYmm9d887Y7Y1ZkyXYHAN4=
90-
github.com/pierrec/lz4/v4 v4.1.19/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
93+
github.com/peterebden/ar v0.0.0-20230524111245-4f7c7b065694 h1:pDBk3JWSIjS3gNxwEk1RjGdyZLsyTW4pOHaShBs9FK8=
94+
github.com/peterebden/ar v0.0.0-20230524111245-4f7c7b065694/go.mod h1:hpFkyhCgB5Rm8FK+ISypOE+9UyrCuL6MNcjPMB1s1ec=
95+
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
96+
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
9197
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
9298
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9399
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
94100
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
95101
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=
96102
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace h1:9PNP1jnUjRhfmGMlkXHjYPishpcw4jpSt/V/xYY3FMA=
97103
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
104+
github.com/sshaman1101/dcompress v0.0.0-20200109162717-50436a6332de h1:uIeuAon/xwRdiZaCmEd5mocquesYkWCf71WBO7obTmA=
105+
github.com/sshaman1101/dcompress v0.0.0-20200109162717-50436a6332de/go.mod h1:XIUpD+1rteMazWrMFjNSpM6TocSHxDYXk6UEgBb5+F0=
98106
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
99107
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
100108
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -103,6 +111,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
103111
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
104112
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
105113
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
114+
github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw=
115+
github.com/therootcompany/xz v1.0.1/go.mod h1:3K3UH1yCKgBneZYhuQUvJ9HPD19UEXEI0BWbMn8qNMY=
106116
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
107117
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
108118
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
@@ -116,6 +126,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
116126
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
117127
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
118128
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
129+
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
119130
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
120131
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
121132
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -235,8 +246,8 @@ golift.io/cnfgfile v0.0.0-20230531075023-f880041cc0a0 h1:u14MTHfTGx7kLX2b3wFbaES
235246
golift.io/cnfgfile v0.0.0-20230531075023-f880041cc0a0/go.mod h1:dVC3N+72/nHNlBv3cwXb4FQTxMAor+JlNClAldwACkY=
236247
golift.io/version v0.0.2 h1:i0gXRuSDHKs4O0sVDUg4+vNIuOxYoXhaxspftu2FRTE=
237248
golift.io/version v0.0.2/go.mod h1:76aHNz8/Pm7CbuxIsDi97jABL5Zui3f2uZxDm4vB6hU=
238-
golift.io/xtractr v0.2.3-0.20240130233802-72495ada05e7 h1:y3hI6nN/DBahF6Hp+/M/vplgnAUJSBeekGnqomzO01Q=
239-
golift.io/xtractr v0.2.3-0.20240130233802-72495ada05e7/go.mod h1:B608A7mLGU3gYciK+GichEUROa/Lp5NNrdmTPBb//o0=
249+
golift.io/xtractr v0.2.3-0.20240202194230-2edf9aff9619 h1:rLCt2Q6zTh3yvs3mw0tujq7FiYq+Q1lc6DDNSV5U7lk=
250+
golift.io/xtractr v0.2.3-0.20240202194230-2edf9aff9619/go.mod h1:B6NSeohycJeS5pur983rw8JUDptMfGldIjqXXtJ65Po=
240251
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
241252
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
242253
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=

main.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/Unpackerr/xt/pkg/xt"
1010
flag "github.com/spf13/pflag"
1111
"golift.io/version"
12+
"golift.io/xtractr"
1213
)
1314

1415
func parseFlags(pwd string) (*xt.Job, *flags) {
@@ -27,12 +28,13 @@ func parseFlags(pwd string) (*xt.Job, *flags) {
2728
flag.StringVarP(&job.Output, "output", "o", pwd, "Output directory, default is current directory")
2829
flag.UintVarP(&job.MaxDepth, "max-depth", "d", 0, "Maximum folder depth to recursively search for archives.")
2930
flag.UintVarP(&job.MinDepth, "min-depth", "m", 0, "Minimum folder depth to recursively search for archives.")
30-
// flag.UintVarP(&job.Recurse, "recurse", "r", 0, "Extract archives inside archives, up to this depth.")
31+
flag.StringSliceVarP(&job.Include, "extension", "e", nil, "Only extract files with these extensions.")
3132
flag.StringSliceVarP(&job.Passwords, "password", "P", nil, "Attempt these passwords for rar and 7zip archives.")
3233
flag.StringSliceVarP(&flags.JobFiles, "job-file", "j", nil, "Read additional extraction jobs from these files.")
34+
flag.Parse()
3335
// Preserve paths?
3436
// flag.BoolVarP(&job.Preserve, "preserve-paths", "", false, "Recreate directory hierarchy while extracting.")
35-
flag.Parse()
37+
// flag.UintVarP(&job.Recurse, "recurse", "r", 0, "Extract archives inside archives, up to this depth.")
3638

3739
job.Paths = flag.Args()
3840

@@ -54,10 +56,7 @@ func main() {
5456

5557
// Get 1 job and other flag info from cli args.
5658
cliJob, flags := parseFlags(pwd)
57-
if flags.PrintVer {
58-
fmt.Printf("xt v%s-%s (%s)\n", version.Version, version.Revision, version.Branch)
59-
os.Exit(0)
60-
}
59+
flags.printVer()
6160

6261
// Read in jobs from 1 or more job files.
6362
jobs, err := xt.ParseJobs(flags.JobFiles)
@@ -81,3 +80,20 @@ func main() {
8180
xt.Extract(job)
8281
}
8382
}
83+
84+
// printVer prints the version and exits.
85+
// Only if the user passed -v or --version.
86+
func (f *flags) printVer() {
87+
if !f.PrintVer {
88+
return
89+
}
90+
91+
fmt.Printf("xt v%s-%s (%s)\n", version.Version, version.Revision, version.Branch)
92+
fmt.Println(" - Supported Extensions:")
93+
94+
for _, ext := range xtractr.SupportedExtensions() {
95+
fmt.Println(" ", ext)
96+
}
97+
98+
os.Exit(0)
99+
}

pkg/xt/job.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Job struct {
1212
Output string `json:"output" yaml:"output" xml:"output" toml:"output"`
1313
Passwords []string `json:"passwords" yaml:"passwords" xml:"password" toml:"passwords"`
1414
Exclude []string `json:"excludeSuffix" yaml:"excludeSuffix" xml:"exclude_suffix" toml:"exclude_suffix"`
15+
Include []string `json:"includeSuffix" yaml:"includeSuffix" xml:"include_suffix" toml:"include_suffix"`
1516
MaxDepth uint `json:"maxDepth" yaml:"maxDepth" xml:"max_depth" toml:"max_depth"`
1617
MinDepth uint `json:"minDepth" yaml:"minDepth" xml:"min_depth" toml:"min_depth"`
1718
DirMode FileMode `json:"dirMode" yaml:"dirMode" xml:"dir_mode" toml:"dir_mode"`

pkg/xt/xt.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@ func (j *Job) getArchives() map[string][]string {
6565
continue
6666
}
6767

68+
exclude := j.Exclude
69+
if len(j.Include) > 0 {
70+
exclude = xtractr.AllExcept(j.Include...)
71+
}
72+
6873
for folder, fileList := range xtractr.FindCompressedFiles(xtractr.Filter{
6974
Path: fileName,
70-
ExcludeSuffix: j.Exclude,
75+
ExcludeSuffix: exclude,
7176
MaxDepth: int(j.MaxDepth),
7277
MinDepth: int(j.MinDepth),
7378
}) {

0 commit comments

Comments
 (0)