can_cli 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -21
- data/can.gemspec +3 -0
- data/lib/can/argparse.rb +11 -8
- data/lib/can/version.rb +1 -1
- data/lib/can.rb +3 -3
- data/lib/trash.rb +4 -4
- data/lib/untrash.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 802816b1df3e8c6731ea2bc7d8fd6cfcecc563e148e5036d9ae5cc7c39322225
|
4
|
+
data.tar.gz: 1d9edb9f93abdff569f55c4642fd20ac124b7375c64731545b22559bcd8efbf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe0f322150b2b80ab2625848e211df9e5b987f15daa07ea0edd5795d95d91fec004cbe96656311ea42e0fc6cb5ff4de2157be574a52ca5cf784bf510bfeac4b6
|
7
|
+
data.tar.gz: 4648ca8f4fe19bdda8c87492fb523d0168897803ad944703bdb72408c4ba6819c669b4803bed5000b5c2d2b380965c145b9c5cac364f23dfce50dfad9af5afe3
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
<h1 style="text-align: center;">can</h1>
|
2
|
+
-----------------------------
|
2
3
|
|
3
4
|
A command line implementation of the [Freedesktop XDG trash
|
4
5
|
specification](https://specifications.freedesktop.org/trash-spec/trashspec-latest.html).
|
@@ -6,42 +7,42 @@ specification](https://specifications.freedesktop.org/trash-spec/trashspec-lates
|
|
6
7
|
Can seeks to follow the behavior of the GNOME Files
|
7
8
|
(Nautilus) trash implementation.
|
8
9
|
|
9
|
-
|
10
|
-
multiple files---it will create an info file for each and
|
11
|
-
move each to the trash directory.
|
10
|
+
## Installation
|
12
11
|
|
13
|
-
|
12
|
+
Can is available as a
|
13
|
+
[Gem](https://rubygems.org/gems/can_cli) and as an [AUR
|
14
|
+
package](https://aur.archlinux.org/packages/can).
|
14
15
|
|
15
|
-
|
16
|
+
Install Gem:
|
17
|
+
`gem install can`
|
16
18
|
|
17
|
-
|
19
|
+
Install on AUR:
|
20
|
+
`paru -S can`
|
18
21
|
|
19
|
-
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
**Does not cover all options**
|
20
25
|
|
21
|
-
|
26
|
+
**Trash files**
|
27
|
+
`can foo.txt bar.txt`
|
22
28
|
|
29
|
+
**Trash directories and files**
|
23
30
|
`can -r foo.txt bar.d`
|
24
31
|
|
25
|
-
|
26
|
-
|
32
|
+
**List files in trashcan**
|
27
33
|
`can -l`
|
28
34
|
|
29
|
-
|
30
|
-
|
35
|
+
**List files in trashcan that match a regex**
|
31
36
|
`can -l '^foo'`
|
32
37
|
|
33
|
-
|
34
|
-
|
38
|
+
**View trashinfo of files**
|
35
39
|
`can -n foo.txt bar.d`
|
36
40
|
|
37
|
-
|
38
|
-
|
41
|
+
**Untrash files**
|
39
42
|
`can -u foo.txt bar.d`
|
40
43
|
|
41
|
-
|
42
|
-
|
44
|
+
**Empty files from trashcan**
|
43
45
|
`can -e foo.txt bar.d`
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
+
**Empty entire trashcan**
|
47
48
|
`can -e`
|
data/can.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/can/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |s|
|
@@ -26,5 +28,6 @@ Gem::Specification.new do |s|
|
|
26
28
|
]
|
27
29
|
s.homepage = 'https://github.com/sawshep/can'
|
28
30
|
s.license = 'GPL-3.0'
|
31
|
+
s.required_ruby_version = '>= 3.0'
|
29
32
|
s.add_runtime_dependency 'highline', '~> 2.0'
|
30
33
|
end
|
data/lib/can/argparse.rb
CHANGED
@@ -4,7 +4,6 @@ require 'optparse'
|
|
4
4
|
require 'set'
|
5
5
|
require 'can/version'
|
6
6
|
|
7
|
-
$options = Set.new
|
8
7
|
|
9
8
|
# This needs to be here because OptParse only looks
|
10
9
|
# at `Version` and @version for the version number,
|
@@ -43,27 +42,31 @@ module Can
|
|
43
42
|
module ArgParse
|
44
43
|
Version = VERSION
|
45
44
|
def self.init_args
|
45
|
+
options = Set.new
|
46
|
+
|
46
47
|
OptionParser.new do |opts|
|
47
48
|
opts.banner = USAGE
|
48
49
|
|
49
50
|
ALL_FLAGS.each do |mode, _v|
|
50
51
|
opts.on(short_opt(mode), long_opt(mode), help_string(mode)) do |_opt|
|
51
|
-
|
52
|
+
options << mode
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end.parse!
|
55
56
|
|
56
|
-
Error.fatal 'Too many mode arguments' if ArgParse.incompatible_opts?
|
57
|
+
Error.fatal 'Too many mode arguments' if ArgParse.incompatible_opts?(options)
|
58
|
+
|
59
|
+
options
|
57
60
|
end
|
58
61
|
|
59
|
-
# Sees if
|
60
|
-
def self.incompatible_opts?
|
62
|
+
# Sees if options has incompatible items
|
63
|
+
def self.incompatible_opts?(options)
|
61
64
|
modes = MODES.keys
|
62
|
-
(
|
65
|
+
(options & modes).length > 1
|
63
66
|
end
|
64
67
|
|
65
|
-
def self.mode
|
66
|
-
(
|
68
|
+
def self.mode(options)
|
69
|
+
(options & MODES.keys).first || :trash
|
67
70
|
end
|
68
71
|
|
69
72
|
def self.short_opt(mode)
|
data/lib/can/version.rb
CHANGED
data/lib/can.rb
CHANGED
@@ -26,14 +26,14 @@ module Can
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.can
|
29
|
-
ArgParse.init_args
|
29
|
+
@options = ArgParse.init_args
|
30
30
|
|
31
|
-
mode = ArgParse.mode
|
31
|
+
mode = ArgParse.mode @options
|
32
32
|
|
33
33
|
init_dirs
|
34
34
|
|
35
35
|
send mode
|
36
36
|
|
37
|
-
$exit = EXIT_SUCCESS if
|
37
|
+
$exit = EXIT_SUCCESS if @options.include?(:force)
|
38
38
|
end
|
39
39
|
end
|
data/lib/trash.rb
CHANGED
@@ -23,7 +23,7 @@ end
|
|
23
23
|
|
24
24
|
module Can
|
25
25
|
def self.trash
|
26
|
-
Error.fatal 'missing operand' if ARGV.empty? &&
|
26
|
+
Error.fatal 'missing operand' if ARGV.empty? && !@options.include?(:force)
|
27
27
|
|
28
28
|
ARGV.each do |path|
|
29
29
|
# TODO: If both `-f` and `-i` are used, can should
|
@@ -31,7 +31,7 @@ module Can
|
|
31
31
|
# can should not prompt trashings. This follows the
|
32
32
|
# behavior of rm.
|
33
33
|
unless File.exist?(path)
|
34
|
-
Error.nonfatal "cannot trash '#{path}': No such file or directory" unless
|
34
|
+
Error.nonfatal "cannot trash '#{path}': No such file or directory" unless @options.include? :force
|
35
35
|
next
|
36
36
|
end
|
37
37
|
|
@@ -39,14 +39,14 @@ module Can
|
|
39
39
|
# argument, a non-zero error code should be returned
|
40
40
|
# regardless if --force is used.
|
41
41
|
if File.directory?(path) && !File.symlink?(path)
|
42
|
-
Error.nonfatal "cannot remove '#{path}': Is a directory" unless
|
42
|
+
Error.nonfatal "cannot remove '#{path}': Is a directory" unless @options.include? :recursive
|
43
43
|
next
|
44
44
|
end
|
45
45
|
|
46
46
|
# TODO: Highline.agree prints to stdout, when it should
|
47
47
|
# print to stderr. It also uses `puts`, while this use
|
48
48
|
# case should use `print`.
|
49
|
-
next if
|
49
|
+
next if @options.include?(:prompt) && !(HighLine.agree "can: remove file '#{path}'?")
|
50
50
|
|
51
51
|
filename = File.basename path
|
52
52
|
|
data/lib/untrash.rb
CHANGED
@@ -6,7 +6,7 @@ module Can
|
|
6
6
|
file_path = File.join(HOME_TRASH_FILES_DIRECTORY, filename)
|
7
7
|
|
8
8
|
unless File.exist? file_path
|
9
|
-
unless
|
9
|
+
unless @options.include? :force
|
10
10
|
Error.nonfatal "cannot untrash '#{filename}': No such file or directory in trash"
|
11
11
|
end
|
12
12
|
next
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: can_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sawyer Shepherd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -58,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '3.0'
|
62
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - ">="
|