richat 0.3.1 → 0.3.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: 956a007844ac17a49095d8a202f0c776b6b00937f090484c5f46a266e71b6fb8
4
- data.tar.gz: 41627a82833e4b75dea99ad96e2e6be6f92f6795b20ee89675d80e048777919b
3
+ metadata.gz: e4e97039d01522133cccb2e0577e36d1d7955b7f4a8f3dad30ca614f4133c57e
4
+ data.tar.gz: 958f913d87344bb797913d569952da0d211a91ebcc09dafa7c3f7da734a6d2b3
5
5
  SHA512:
6
- metadata.gz: 1fb5a56058312251ff31bc8331424440b856156b1cfa6403ee428c363a872cb0a8635bb9d86a16e0aef65737da0fd8973167f49eaa720bb7604f3e7fe9081903
7
- data.tar.gz: ed83c9c9c93bd6c065d46f62664e355454b677f8cac01d5018774c418b7f5f231db335f2e66c9c6cb16c28829b30ae886f5c3b63240e32f612bd8ac709c9adc7
6
+ metadata.gz: 31739062cb92784a44589feea8b2db3c43f0c9213ba748a66f46d10065e71a0d0aef07a5c7f30fd3a9f0f7849b714d5994b3dad887928789a0683b004402724e
7
+ data.tar.gz: c892747d24725cb3f793763317de4a522043fd0e4220463a4a07843636f78757f64c618e993898d35196e0b63345df7e15e0e8db73f0826243928d611723cd2c
@@ -42,17 +42,42 @@ 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? || !process_exist?
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
+
72
+ def process_exist?
73
+ begin
74
+ Process.getpgid(@pid)
75
+ true
76
+ rescue
77
+ false
78
+ end
79
+ end
80
+
56
81
  def handle_config
57
82
  puts "\e[32mConfiguration file path is #{File.expand_path("~/.richat/config.json")}\e[0m"
58
83
  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.3"
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.3
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