ememo 0.1.4 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35db92f0126a5f4ef698af2cda893453c1d57dbe11b9da1b0e46db540124b8bc
4
- data.tar.gz: d0fdba4fa16198a18c2619be0bc6dcae2c545a9540a69df862653dfeb0cf3c3b
3
+ metadata.gz: 6545661137c4a142895358a1b7f68be26bad4272c89cb79395b370edd0a5f374
4
+ data.tar.gz: '087ad9cc671dfea8e2ecd0b69e13caef9c9b55c80c7484c93e8794059c58ce86'
5
5
  SHA512:
6
- metadata.gz: 829ade64bd8705d62474c6bc211b78be3f30ee2e682a38f9bab4b2199cf279402977814b04f75845fe877650f5c3684dee857430685961ab244bf277da354cb9
7
- data.tar.gz: 88dede1401224b2857e86ee7e37437d7a6650191dca019810377e5c33b28c2b5319e0c5e2b34fee4c7852b8a9167b9ffa85150c7d0487550ee4cbc0bc1bc6649
6
+ metadata.gz: b2fc5d6ee9c9e33cd3b28e800eb0cccee725e0ca397a304b8091f9e39dfb4382e4ebfb855b254ab0e6700ad8add32bc919afa4c4891b4dd252b8821d6f8f9ea9
7
+ data.tar.gz: c6d7450843d17dd4e666c2fcefe4993f426799b399d3a7f1e79ca30bc995a3ce0ec2b89df76946da64368c6db73c77c1520fc3350c4c998ca5cc7f8080c03496
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ememo (0.1.4)
4
+ ememo (0.2.0)
5
5
  tomlrb
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -70,8 +70,32 @@ $ memo p todo -n project1
70
70
  # with namespace_alias
71
71
  $ memo p todo -n p
72
72
 
73
+ # copy to clipboard
74
+ $ memo p todo -n p -c
75
+ $ memo p todo -n p -copy
76
+
77
+ # preview config
78
+ $ memo p c
79
+ $ memo p config
73
80
  ```
74
81
 
82
+ ### List
83
+ ```bash
84
+ # list of ~/.memo/mymemo
85
+ $ memo l
86
+ $ memo list
87
+
88
+ # list ~/.memo/project1
89
+ $ memo l -n project1
90
+
91
+ # all
92
+ $ memo l -a
93
+ $ memo l -all
94
+
95
+ # list of direcory
96
+ $ memo l -d
97
+ $ memo l -dir
98
+ ```
75
99
  ### Today
76
100
  ```bash
77
101
  # edit today's memo (~/.memo/2021/1/1.md)
@@ -115,6 +139,8 @@ $ memo ptw
115
139
  ext = "md"
116
140
  root = "~/.memo"
117
141
  editor = "vim"
142
+ # pbcopy = "pbcopy"
143
+ pbcopy = "xsel --clipboard --input"
118
144
  preview = "bat"
119
145
  fuzzy_finder = "fzf --preview 'bat --color=always {}'"
120
146
  default_filename = "memo"
@@ -123,6 +149,7 @@ default_namespace = "general"
123
149
  [namespace_alias]
124
150
  w = "work"
125
151
  p = "private"
152
+ w1 = "work/project1"
126
153
 
127
154
  [command_alias]
128
155
  etw = "e todo -n w"
@@ -3,19 +3,41 @@ module Memo
3
3
  attr_reader :namespace
4
4
 
5
5
  def initialize(args)
6
- @args = args.to_a
6
+ @raw_args = args.to_a
7
7
 
8
- case args
8
+ case @raw_args
9
9
  in [*, "-n", namespace, *]
10
10
  @namespace = namespace
11
- @args.delete("-n")
12
- @args.delete(namespace)
11
+ @raw_args.delete("-n")
12
+ @raw_args.delete(namespace)
13
13
  else
14
14
  end
15
+
16
+ @args = @raw_args.select do |s|
17
+ !s.start_with? "-"
18
+ end
15
19
  end
16
20
 
17
21
  def [](index)
18
22
  @args[index]
19
23
  end
24
+
25
+ def dir?
26
+ include_any? "-dir", "-d"
27
+ end
28
+
29
+ def all?
30
+ include_any? "-all", "-a"
31
+ end
32
+
33
+ def copy?
34
+ include_any? "-copy", "-c"
35
+ end
36
+
37
+ private
38
+
39
+ def include_any?(*args)
40
+ args.map { |a| @raw_args.include?(a) }.any?
41
+ end
20
42
  end
21
43
  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"
@@ -17,7 +17,7 @@ module Memo
17
17
 
18
18
  if input.nil?
19
19
  puts Error::Unknown.new.to_s
20
- puts Usage::Help.new.to_s
20
+ puts Memo::Usage.new.to_s
21
21
  return
22
22
  end
23
23
 
@@ -5,7 +5,7 @@ module Memo
5
5
  def initialize(*); end
6
6
 
7
7
  def call
8
- puts Usage::Help.new.to_s
8
+ puts Memo::Usage.new.to_s
9
9
  end
10
10
  end
11
11
  end
@@ -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.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,17 +15,27 @@ 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
- @today.fullpath
21
+ "#{@config.root}/#{@today.fullpath}"
22
+ when "config", "c"
23
+ @config.path
21
24
  else
22
- Memo::File.new(
25
+ p = Memo::File.new(
23
26
  filename,
24
27
  @options.namespace,
25
28
  ).fullpath
29
+
30
+ "#{@config.root}/#{p}"
26
31
  end
27
32
 
28
- @os.exec "#{@config.preview} #{@config.root}/#{path}"
33
+ cmd ="#{@config.preview} #{path}"
34
+ if @options.copy?
35
+ @os.exec "#{cmd} | (#{@config.pbcopy})"
36
+ end
37
+
38
+ @os.exec cmd
29
39
  end
30
40
  end
31
41
  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
@@ -7,7 +7,7 @@ module Memo
7
7
  end
8
8
 
9
9
  def dir = "#{@year}/#{@month}"
10
- def file = "#{@day}.#{@config.ext}"
10
+ def file = "#{@day}.#{@config.ext}"
11
11
  def fullpath = "#{dir}/#{file}"
12
12
  end
13
13
  end
@@ -0,0 +1,50 @@
1
+ module Memo
2
+ class Usage
3
+ def to_s
4
+ <<~TEXT
5
+ EASY EDIT MEMO
6
+
7
+ USAGE
8
+ - Config
9
+ You can edit basic config and register aliases
10
+
11
+ $ memo c
12
+ $ memo config
13
+
14
+ - Edit
15
+ $ memo e
16
+ $ memo edit
17
+ $ memo edit todo
18
+ $ memo edit todo -n project1
19
+ $ memo edit todo -n p # use namespace_alias
20
+
21
+ - Preview
22
+ $ memo p
23
+ $ memo preview
24
+ $ memo p todo
25
+ $ memo p todo -n project1
26
+ $ memo p todo -n p # use namespace_alias
27
+
28
+ - Today
29
+ # edit
30
+ $ memo t
31
+ $ memo today
32
+
33
+ # preview
34
+ $ memo preview today
35
+ $ memo p t
36
+
37
+ - Fuzzy
38
+ $ memo fuzzy
39
+ $ memo f
40
+
41
+ - Custom Command
42
+ $ memo todo # use command_alias
43
+
44
+ - Confirm Alias
45
+ $ memo a
46
+ $ memo alias
47
+ TEXT
48
+ end
49
+ end
50
+ 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.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuma Ishikawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-14 00:00:00.000000000 Z
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb
@@ -52,19 +52,17 @@ 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
58
59
  - lib/memo/cli/config/config.rb
59
60
  - lib/memo/cli/error/error.rb
60
- - lib/memo/cli/usage/config.rb
61
- - lib/memo/cli/usage/help.rb
62
- - lib/memo/cli/usage/new.rb
63
- - lib/memo/cli/usage/preview.rb
64
61
  - lib/memo/os/os.rb
65
62
  - lib/memo/value/default.rb
66
63
  - lib/memo/value/file.rb
67
64
  - lib/memo/value/today.rb
65
+ - lib/memo/value/usage.rb
68
66
  - lib/memo/version.rb
69
67
  - memo.gemspec
70
68
  homepage: https://github.com/YumaFuu/ememo
@@ -1,13 +0,0 @@
1
- module Memo
2
- class Cli
3
- module Usage
4
- class Config
5
- def to_s
6
- <<~TEXT
7
- $ memo config
8
- TEXT
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,50 +0,0 @@
1
- module Memo
2
- class Cli
3
- module Usage
4
- class Help
5
- def to_s
6
- <<~TEXT
7
- EASY EDIT MEMO
8
-
9
- USAGE
10
- - Config
11
- You can edit basic config and register aliases
12
-
13
- $ memo c
14
- $ memo config
15
-
16
- - Edit
17
- $ memo e
18
- $ memo edit
19
- $ memo edit todo
20
- $ memo edit todo -n project1
21
- $ memo edit todo -n p # use namespace_alias
22
-
23
- - Preview
24
- $ memo p
25
- $ memo preview
26
- $ memo p todo
27
- $ memo p todo -n project1
28
- $ memo p todo -n p # use namespace_alias
29
-
30
- - Today
31
- # edit
32
- $ memo t
33
- $ memo today
34
-
35
- # preview
36
- $ memo preview today
37
- $ memo p t
38
-
39
- - Fuzzy
40
- $ memo fuzzy
41
- $ memo f
42
-
43
- - Custom Command
44
- $ memo todo # use command_alias
45
- TEXT
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,21 +0,0 @@
1
- module Memo
2
- class Cli
3
- module Usage
4
- class New
5
- def initialize(err:)
6
- @err = err
7
- end
8
-
9
- def to_s
10
- <<~TEXT
11
- #{@err}
12
-
13
- usage:
14
- $ memo new new-memo
15
- $ memo n new-memo
16
- TEXT
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- module Memo
2
- class Cli
3
- module Usage
4
- class Preview
5
- def initialize(err:)
6
- @err = err.to_s
7
- end
8
-
9
- def to_s
10
- <<~TEXT
11
- #{@err}
12
-
13
- usage:
14
- $ memo preview my-memo
15
- TEXT
16
- end
17
- end
18
- end
19
- end
20
- end