ememo 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35db92f0126a5f4ef698af2cda893453c1d57dbe11b9da1b0e46db540124b8bc
4
- data.tar.gz: d0fdba4fa16198a18c2619be0bc6dcae2c545a9540a69df862653dfeb0cf3c3b
3
+ metadata.gz: e4b3d31da2c1d05c05ae32ffadda4405058e3d48e19ffd107be678d9de6abba6
4
+ data.tar.gz: a2e0b0a3ed71be0393b968322a4b49a709540eb99d58feb8cd6f64905ae2b5e0
5
5
  SHA512:
6
- metadata.gz: 829ade64bd8705d62474c6bc211b78be3f30ee2e682a38f9bab4b2199cf279402977814b04f75845fe877650f5c3684dee857430685961ab244bf277da354cb9
7
- data.tar.gz: 88dede1401224b2857e86ee7e37437d7a6650191dca019810377e5c33b28c2b5319e0c5e2b34fee4c7852b8a9167b9ffa85150c7d0487550ee4cbc0bc1bc6649
6
+ metadata.gz: a212d5333fab990df1f2d18e0986374328f43233cdeab90cc087f6026a6a3b252e955cc6b37a648ee2c799f44dfea0322e71ef7675b2ccf3d049c9f917e4f562
7
+ data.tar.gz: 49663115e04d61aedfc55c80b87d0e18c375d6978f3f5d63e05dde6990470471095bc5e60edd1c3b6017415c195e2dea7faa374128b883a87a154996062395eb
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ememo (0.1.4)
4
+ ememo (0.1.5)
5
5
  tomlrb
6
6
 
7
7
  GEM
@@ -1,9 +1,11 @@
1
1
  module Memo
2
2
  class Option
3
- attr_reader :namespace
3
+ attr_reader :namespace, :is_all
4
4
 
5
5
  def initialize(args)
6
6
  @args = args.to_a
7
+ @is_all = args.include?("-a") ||
8
+ args.include?("-all")
7
9
 
8
10
  case args
9
11
  in [*, "-n", namespace, *]
@@ -17,5 +19,23 @@ module Memo
17
19
  def [](index)
18
20
  @args[index]
19
21
  end
22
+
23
+ def dir?
24
+ include_any? "-dir", "-d"
25
+ end
26
+
27
+ def all?
28
+ include_any? "-all", "-a"
29
+ end
30
+
31
+ def copy?
32
+ include_any? "-copy", "-c"
33
+ end
34
+
35
+ private
36
+
37
+ def include_any?(*args)
38
+ args.map { |a| @args.include?(a) }.any?
39
+ end
20
40
  end
21
41
  end
@@ -17,6 +17,8 @@ module Memo
17
17
  Command::Preview
18
18
  when "today", "t"
19
19
  Command::Today
20
+ when "list", "l"
21
+ Command::List
20
22
  when "config", "c"
21
23
  Command::Config
22
24
  when "help", "h"
@@ -0,0 +1,33 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class List
5
+ def initialize(
6
+ options,
7
+ os: Memo::OS.new
8
+ )
9
+ @options = options
10
+ @os = os
11
+ @config = Memo::Config.new
12
+ end
13
+
14
+ def call
15
+ namespace = @options.namespace
16
+ is_all = @options.is_all
17
+ type = @options.dir? ? "d" : "f"
18
+
19
+ dir = if is_all
20
+ ""
21
+ else
22
+ Memo::File.new(
23
+ "",
24
+ @options.namespace,
25
+ ).dir
26
+ end
27
+
28
+ @os.exec "find #{@config.root}/#{dir} -type #{type}"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -15,6 +15,7 @@ module Memo
15
15
 
16
16
  def call
17
17
  filename = @options[0]
18
+
18
19
  path = case filename
19
20
  when "today", "t"
20
21
  @today.fullpath
@@ -25,7 +26,12 @@ module Memo
25
26
  ).fullpath
26
27
  end
27
28
 
28
- @os.exec "#{@config.preview} #{@config.root}/#{path}"
29
+ cmd ="#{@config.preview} #{@config.root}/#{path}"
30
+ if @options.copy?
31
+ @os.exec "#{cmd} | (#{@config.pbcopy})"
32
+ end
33
+
34
+ @os.exec cmd
29
35
  end
30
36
  end
31
37
  end
@@ -24,6 +24,7 @@ module Memo
24
24
 
25
25
  def ext = @config[:ext] || Default::Ext.to_s
26
26
  def root = @config[:root] || Default::Root.to_s
27
+ def pbcopy = @config[:pbcopy] || Default::Pbcopy.to_s
27
28
  def preview = @config[:preview] || Default::Preview.to_s
28
29
 
29
30
  def fuzzy_finder = @config[:fuzzy_finder] ||
@@ -8,6 +8,10 @@ module Memo
8
8
  def self.to_s = "cat"
9
9
  end
10
10
 
11
+ class Pbcopy
12
+ def self.to_s = "pbcopy"
13
+ end
14
+
11
15
  class Root
12
16
  def self.to_s = "~/.memo"
13
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Memo
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ememo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuma Ishikawa
@@ -52,6 +52,7 @@ files:
52
52
  - lib/memo/cli/command/edit.rb
53
53
  - lib/memo/cli/command/fuzzy.rb
54
54
  - lib/memo/cli/command/help.rb
55
+ - lib/memo/cli/command/list.rb
55
56
  - lib/memo/cli/command/preview.rb
56
57
  - lib/memo/cli/command/setup.rb
57
58
  - lib/memo/cli/command/today.rb