dorian-top 0.2.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/top +29 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ef9385fea753248a45832426e9271a0c8eb2ca266d541136e347fbf03bf8b2f
4
- data.tar.gz: eb0b0d76340d7e696d0c12bb573ad5430ab2f8c7d16bd379a7ccf131ef2a33ec
3
+ metadata.gz: 7fcf8105bc630b9c030a57cfbc950cd0858789ea42a1a46172a17c91699f8948
4
+ data.tar.gz: 6b487c3639faebcb782b1ee660f0ebe4eba50c413fa7bba1c83413ed526a7b3f
5
5
  SHA512:
6
- metadata.gz: 6b7aa2677721b6dcc3a32fa6082accdc19cb690ea83048ddf5b06a6364f300e81594599535ce85e3ce42dc189325f251d0e988a91d408bc3b4a3f50ff5790c38
7
- data.tar.gz: ce8750383ed9f3b6645c701d9de32506c7319bc0f2ac3822acead20cad8c4185030c1aebe40a9ecc90facd7ff445e67a691990e8fe60ceb66f5d8abfad6e91b7
6
+ metadata.gz: af8d343a95eef1e202bde9ab73b965ab2f66d13aef892d936d1349fe44a714e3bdc1d71d7656327774b97f036481f2fb776e787290361739639efa74342d1c0b
7
+ data.tar.gz: beb27edf337c5873d03040e86bad71be8026d83e270b42e034d979307a2518d233a77678c4e7fbff2a43c472f5e137013b312b033f7958c649faa582149b24cd
data/bin/top CHANGED
@@ -1,16 +1,36 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- if ARGV.size > 2 || ARGV.first == "-h" || ARGV.first == "--help"
5
- puts "USAGE: top [N] [SHELL]"
6
- exit
7
- end
4
+ require "dorian/arguments"
5
+
6
+ parsed =
7
+ Dorian::Arguments.parse(
8
+ limit: {
9
+ type: :integer,
10
+ aliases: %i[l n],
11
+ default: 10
12
+ },
13
+ shell: {
14
+ type: :string,
15
+ alias: :s,
16
+ default: File.basename(ENV["SHELL"] || "bash")
17
+ },
18
+ version: {
19
+ alias: :v
20
+ },
21
+ help: {
22
+ alias: :h
23
+ }
24
+ )
8
25
 
9
- N = (ARGV.first || 10).to_i
10
- SHELL = File.basename(ARGV.last || ENV["SHELL"] || "bash")
26
+ abort parsed.help if parsed.options.help
27
+
28
+ if parsed.options.version
29
+ abort File.read(File.expand_path("../../VERSION", __FILE__))
30
+ end
11
31
 
12
32
  HISTORY =
13
- case SHELL
33
+ case parsed.options.shell.to_s.downcase
14
34
  when "fish"
15
35
  File
16
36
  .read("#{Dir.home}/.local/share/fish/fish_history")
@@ -22,7 +42,7 @@ HISTORY =
22
42
  when "zsh"
23
43
  File.read("#{Dir.home}/.zsh_history").lines.map(&:strip)
24
44
  else
25
- raise NotImplementedError, SHELL
45
+ raise NotImplementedError, parsed.options.shell.to_s.downcase
26
46
  end
27
47
 
28
48
  puts(
@@ -40,5 +60,5 @@ puts(
40
60
  "#{(command_count * 100 / HISTORY.size.to_f).round(3)}%\t" \
41
61
  "#{command}"
42
62
  end
43
- .first(N)
63
+ .first(parsed.options.limit)
44
64
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-top
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-22 00:00:00.000000000 Z
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dorian-arguments