work-md 0.4.2 → 0.4.3

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: f71380cbbd01039015727e92f5de5e621b1a3511914e4a6b81ef50de192ea43d
4
- data.tar.gz: 7952a1d0d8c232a40ac18bdf90ff5f3b728aa57b3868170821204136492b04ff
3
+ metadata.gz: 7f44d4a6782b7211c58b01812b8ad00048ac2509abbdc60a20397dd2c16ee3a3
4
+ data.tar.gz: e1bc2d24ec7dbe29540e0105663d31c93b8da49c5a29056217ff6c7d311dee60
5
5
  SHA512:
6
- metadata.gz: 11d3bc8deb4aa7ba041a171a28b825eed5ce1690a53644ab331583f219f970a58c1dfcfcf7c95460e4ab2634efad01f5bdfe9e68a754da7f859ae40c43ab9a5d
7
- data.tar.gz: e4a5616a87b0d249ef703b775f6956af217f578bd9fc3cd88e2becd43a45d96f5daed154704e174c7e1724cf703234be2e848e5e805932275b407727c709cef6
6
+ metadata.gz: 587defdc3bf40c0801ea7b1f624974345e2c112cecb6417637fac295891066735440f43c3845574c524357c36453e2b84a33ade5b4ff62881f475cc3c3ecc200
7
+ data.tar.gz: 96389252eabac8037b98e2f05d56fab7631b64df53f99bc727cac903e80ffd9c22251f80ab9a29175f8768f9a11c7b9178bb68653fdaf2bd062db9120b7ff441
data/lib/work/md/cli.rb CHANGED
@@ -20,6 +20,14 @@ module Work
20
20
 
21
21
  def self.execute(argv)
22
22
  first_argv_argument = argv.shift
23
+ tag = fetch_argv_keys(argv)['tag']
24
+
25
+ if tag
26
+ ENV['WORK_MD_TAG'] = tag
27
+ argv.reject! { |arg| arg.include?('-tag=') }
28
+ end
29
+
30
+ ::FileUtils.mkdir_p(Work::Md::Config.work_dir)
23
31
 
24
32
  raise CommandMissing if first_argv_argument.nil?
25
33
 
@@ -30,7 +38,7 @@ module Work
30
38
  Object
31
39
  .const_get("Work::Md::Commands::#{command}")
32
40
  .send(:execute, argv)
33
- rescue NameError => e
41
+ rescue NameError
34
42
  puts help(
35
43
  ::TTY::Box.frame(
36
44
  "Command '#{first_argv_argument}' not found!",
@@ -56,10 +64,11 @@ module Work
56
64
  '- work-md last',
57
65
  '- work-md tlast',
58
66
  '- work-md parse',
67
+ '- work-md plast',
59
68
  '- work-md annotations',
60
69
  '- work-md config',
61
70
  '',
62
- 'more information in github.com/work-md',
71
+ 'for more information: github.com/work-md',
63
72
  padding: 1,
64
73
  title: { top_left: '(work-md)', bottom_right: "(v#{Work::Md::VERSION})" }
65
74
  )
@@ -72,6 +81,10 @@ module Work
72
81
  title: { top_left: '(error)' }
73
82
  }
74
83
  end
84
+
85
+ def self.fetch_argv_keys(argv)
86
+ Hash[argv.join(' ').scan(/-?([^=\s]+)(?:=(\S+))?/)]
87
+ end
75
88
  end
76
89
  end
77
90
  end
@@ -7,9 +7,9 @@ module Work
7
7
  class << self
8
8
  def execute(argv = [])
9
9
  parser = Work::Md::Parser::Engine.new
10
- args_hash_to_parser = -> (args, received_parser) {
11
- year = args['y'] || Time.new.year
12
- month = args['m'] || Time.new.month
10
+ argv_keys_to_parser = -> (argv_keys, received_parser) {
11
+ year = argv_keys['y'] || Time.new.year
12
+ month = argv_keys['m'] || Time.new.month
13
13
 
14
14
  month = "0#{month.to_i}" if month.to_i < 10
15
15
 
@@ -21,27 +21,26 @@ module Work
21
21
  received_parser.add_file(file_name)
22
22
  end
23
23
 
24
- if args['d'].include?('..')
25
- range = args['d'].split('..')
24
+ if argv_keys['d'].include?('..')
25
+ range = argv_keys['d'].split('..')
26
26
 
27
27
  (range[0].to_i..range[1].to_i).each { |day| add_file_to_parser.call(day) }
28
28
  else
29
- args['d'].split(',').each { |day| add_file_to_parser.call(day) }
29
+ argv_keys['d'].split(',').each { |day| add_file_to_parser.call(day) }
30
30
  end
31
31
 
32
32
  received_parser
33
33
  }
34
34
 
35
35
  argv.join('#').split('#and#').map { |v| v.split("#") }.each do |args|
36
- args_hash = Hash[args.join(' ').scan(/-?([^=\s]+)(?:=(\S+))?/)]
37
- args_hash_to_parser.(args_hash, parser)
36
+ argv_keys_to_parser.(Work::Md::Cli.fetch_argv_keys(args), parser)
38
37
  end
39
38
 
40
39
  Work::Md::File.create_and_open_parsed(parser)
41
- rescue StandardError => e
40
+ rescue StandardError
42
41
  Work::Md::Cli.help(
43
42
  ::TTY::Box.frame(
44
- "message: #{e.message}",
43
+ "message: Some of verified markdown files may be with an incorrect format",
45
44
  '',
46
45
  'Usage examples:',
47
46
  '',
@@ -23,6 +23,17 @@ module Work
23
23
  end
24
24
 
25
25
  Work::Md::File.create_and_open_parsed(parser)
26
+ rescue StandardError
27
+ Work::Md::Cli.help(
28
+ ::TTY::Box.frame(
29
+ "message: Some of verified markdown files may be with an incorrect format",
30
+ '',
31
+ 'Usage example:',
32
+ '',
33
+ 'work-md pl 7 # parse the last 7 days',
34
+ **Work::Md::Cli.error_frame_style
35
+ )
36
+ )
26
37
  end
27
38
  end
28
39
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Work
4
4
  module Md
5
- VERSION = '0.4.2'
5
+ VERSION = '0.4.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: work-md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique Fernandez Teixeira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-21 00:00:00.000000000 Z
11
+ date: 2021-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-box