Skip to content

Commit c74933f

Browse files
committed
improve picoline and nmcli
1 parent 6ad3b19 commit c74933f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

mrbgems/picoruby-editor/mrblib/editor.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ def start
223223
history_head
224224
when 4 # Ctrl-D logout
225225
puts
226-
return
226+
puts "^D\e[0J"
227+
raise "Abort"
227228
when 5 # Ctrl-E
228229
@buffer.tail
229230
when 9

mrbgems/picoruby-picoline/mrblib/picoline.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def ask(prompt, allow_empty: false)
5757
break buffer.lines[0].chomp
5858
end
5959
end
60-
answer = q.default.to_s if answer.empty?
61-
break if !answer.empty? || allow_empty
60+
answer = q.default.to_s if answer.to_s.empty?
61+
break if !answer.to_s.empty? || allow_empty
6262
end
6363
return(@answer = answer)
6464
end

mrbgems/picoruby-shell/shell_executables/nmcli.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
tag + ciphertext
2121
end
2222

23+
puts "Ctrd-D to exit"
2324
cli = PicoLine.new
2425
answers = {"wifi" => {}}
2526

@@ -28,10 +29,10 @@
2829
end
2930
answers["wifi"]["ssid"] = cli.ask("WiFi SSID?")
3031
password = cli.ask("WiFi Password? (leave blank if no password required)", allow_empty: true)
31-
answers["wifi"]["encoded_password"] = if !password.empty?
32-
Base64.encode64(encrypt_proc.call(password))
33-
else
32+
answers["wifi"]["encoded_password"] = if password.nil? || password.empty?
3433
nil
34+
else
35+
Base64.encode64(encrypt_proc.call(password))
3536
end
3637
answers["wifi"]["auto_connect"] = cli.ask("Auto Connect? (y/n)") do |q|
3738
q.default = "y"

0 commit comments

Comments
 (0)