richat 0.3.1 → 0.3.2

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: 956a007844ac17a49095d8a202f0c776b6b00937f090484c5f46a266e71b6fb8
4
- data.tar.gz: 41627a82833e4b75dea99ad96e2e6be6f92f6795b20ee89675d80e048777919b
3
+ metadata.gz: bb3631228142f53230643f479f14be326d6e091ed32d803bd45753e81ffd2d83
4
+ data.tar.gz: 59ee64555d89887ca356dfe520dae3b8a8f816eb72b86be87058e9d5c4b4f63c
5
5
  SHA512:
6
- metadata.gz: 1fb5a56058312251ff31bc8331424440b856156b1cfa6403ee428c363a872cb0a8635bb9d86a16e0aef65737da0fd8973167f49eaa720bb7604f3e7fe9081903
7
- data.tar.gz: ed83c9c9c93bd6c065d46f62664e355454b677f8cac01d5018774c418b7f5f231db335f2e66c9c6cb16c28829b30ae886f5c3b63240e32f612bd8ac709c9adc7
6
+ metadata.gz: 36d03a95e5283bf1ce16ec01e115bede4251e48bd4edfc1298bfeb06b397535f2928ccbcb770efd54d46f1824165611316118025f47ebf7f2080c46ad476c294
7
+ data.tar.gz: 904a8173b63e955b60d48fba52c53186dfcea006c4f361ec0bb739bc6773179628f018811843c32730db2e75ccc7eeb23b19d1c78ae9332952fd60ca571faf1e
@@ -42,17 +42,33 @@ module Richat
42
42
  puts "cd: no such file or directory: #{fp}"
43
43
  end
44
44
  else
45
- system(cmd)
45
+ @pid = Process.spawn(cmd)
46
+ Process.wait(@pid)
46
47
  end
47
48
 
48
49
  NEXT_CODE
49
50
  end
50
51
 
51
52
  def handle_exit
52
- puts "Bye"
53
+ kill_process
54
+ puts "Bye!"
53
55
  EXIT_CODE
54
56
  end
55
57
 
58
+ def kill_process
59
+ return if @pid.nil?
60
+ if Gem.win_platform?
61
+ system("taskkill /F /PID #{@pid}")
62
+ else
63
+ begin
64
+ Process.kill("TERM", @pid)
65
+ rescue
66
+ nil
67
+ end
68
+ end
69
+ @pid = nil
70
+ end
71
+
56
72
  def handle_config
57
73
  puts "\e[32mConfiguration file path is #{File.expand_path("~/.richat/config.json")}\e[0m"
58
74
  puts JSON.pretty_generate(Config.get_config)
data/lib/richat/shell.rb CHANGED
@@ -86,7 +86,21 @@ module Richat
86
86
 
87
87
  puts
88
88
  end
89
- rescue SignalException, Exception => e
89
+ rescue Interrupt
90
+ if sys_cmd_mode
91
+ Command.kill_process
92
+ retry
93
+ else
94
+ Command.handle_exit
95
+ end
96
+ rescue SystemCallError => e
97
+ puts e.message
98
+ if sys_cmd_mode
99
+ retry
100
+ else
101
+ Command.handle_exit
102
+ end
103
+ rescue Exception => e
90
104
  puts e.message
91
105
  Command.handle_exit
92
106
  end
@@ -1,3 +1,3 @@
1
1
  module Richat
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: richat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - fzdp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-09 00:00:00.000000000 Z
11
+ date: 2023-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.0.9
111
+ rubygems_version: 3.4.10
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Richat is a command-line ChatGPT tool