mysh 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mysh.rb +1 -2
- data/lib/mysh/commands/cd.rb +2 -1
- data/lib/mysh/version.rb +1 -1
- data/mysh.gemspec +1 -1
- metadata +4 -5
- data/lib/mysh/auto_file.rb +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56a76283a8d651321e0120c508b5402ebc91d9ae
|
4
|
+
data.tar.gz: 52eb191af673c9494000f23f254f24f8b5e906e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b6d2bebfd47526c31af93b646d084041de6e623733376e5937b7c4ce2cc054ba384583a97e0feb79354c9a234947cdc24efb01234c1791f2b88f87780305a1
|
7
|
+
data.tar.gz: 593a900c74fd535984bd7554f90f45e94f3316d905dfd1fec44383f412fe7dc24082866a7dee757a9096a6a6306c7050a778fba22740093fa50466c4a9754ad9
|
data/lib/mysh.rb
CHANGED
@@ -9,7 +9,6 @@ require 'English'
|
|
9
9
|
$no_alias_read_line_module = true
|
10
10
|
require 'mini_readline'
|
11
11
|
|
12
|
-
require_relative 'mysh/auto_file'
|
13
12
|
require_relative 'mysh/internal'
|
14
13
|
require_relative 'mysh/expression'
|
15
14
|
require_relative 'mysh/version'
|
@@ -30,7 +29,7 @@ module Mysh
|
|
30
29
|
@input = MiniReadline::Readline.new(history: true,
|
31
30
|
eoi_detect: true,
|
32
31
|
auto_complete: true,
|
33
|
-
auto_source:
|
32
|
+
auto_source: MiniReadline::AutoFileSource)
|
34
33
|
|
35
34
|
loop do
|
36
35
|
input = @input.readline(prompt: 'mysh> ')
|
data/lib/mysh/commands/cd.rb
CHANGED
@@ -6,7 +6,8 @@ module Mysh
|
|
6
6
|
#* cd.rb -- The mysh internal cd command.
|
7
7
|
class InternalCommand
|
8
8
|
#Add the cd command to the library.
|
9
|
-
|
9
|
+
desc = 'Change directory to <dir> and display the new working directory.'
|
10
|
+
add(self.new('cd <dir>', desc) do |args|
|
10
11
|
begin
|
11
12
|
Dir.chdir(args[0]) unless args.empty?
|
12
13
|
puts decorate(Dir.pwd)
|
data/lib/mysh/version.rb
CHANGED
data/mysh.gemspec
CHANGED
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'minitest_visible', ">= 0.1.1"
|
31
31
|
spec.add_development_dependency 'rdoc', "~> 4.0.1"
|
32
32
|
|
33
|
-
spec.add_runtime_dependency 'mini_readline', ">= 0.
|
33
|
+
spec.add_runtime_dependency 'mini_readline', ">= 0.6.0"
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.6.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.6.0
|
111
111
|
description: mysh -- a Ruby inspired command shell for CLI and application use.
|
112
112
|
email:
|
113
113
|
- peter.c.camilleri@gmail.com
|
@@ -122,7 +122,6 @@ files:
|
|
122
122
|
- README.md
|
123
123
|
- bin/mysh
|
124
124
|
- lib/mysh.rb
|
125
|
-
- lib/mysh/auto_file.rb
|
126
125
|
- lib/mysh/commands/cd.rb
|
127
126
|
- lib/mysh/commands/exit.rb
|
128
127
|
- lib/mysh/commands/help.rb
|
data/lib/mysh/auto_file.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
#* auto_file.rb - The data source for mysh file name auto-complete.
|
4
|
-
module Mysh
|
5
|
-
|
6
|
-
#* auto_file.rb - The data source for mysh file name auto-complete.
|
7
|
-
class AutoFile
|
8
|
-
|
9
|
-
#Create a new file/folder auto-data source. NOP
|
10
|
-
def initialize(_options); end
|
11
|
-
|
12
|
-
#Construct a new data list for auto-complete
|
13
|
-
def rebuild(str)
|
14
|
-
extract_root_pivot(str)
|
15
|
-
|
16
|
-
list = Dir.glob(dress_down(@pivot) + '*')
|
17
|
-
|
18
|
-
@cycler = list.empty? ? nil : list.cycle
|
19
|
-
end
|
20
|
-
|
21
|
-
#The regex for extraction of the root and pivot.
|
22
|
-
EXTRACT = /("[^"\s][^"]*"?$)|(\S+$)/
|
23
|
-
|
24
|
-
#Parse the string into the two basic components.
|
25
|
-
def extract_root_pivot(str)
|
26
|
-
@root, @pivot = EXTRACT =~ str ? [$PREMATCH, $MATCH] : [str, ""]
|
27
|
-
end
|
28
|
-
|
29
|
-
#Get the next string for auto-complete
|
30
|
-
def next
|
31
|
-
@root + dress_up(@cycler.next)
|
32
|
-
end
|
33
|
-
|
34
|
-
#Prepare the file name for internal use.
|
35
|
-
#<br>Endemic Code Smells
|
36
|
-
#* :reek:UtilityFunction
|
37
|
-
def dress_down(name)
|
38
|
-
name.gsub("\\", "/").gsub('"', '')
|
39
|
-
end
|
40
|
-
|
41
|
-
#Prepare the file name for external use.
|
42
|
-
#<br>Endemic Code Smells
|
43
|
-
#* :reek:UtilityFunction
|
44
|
-
def dress_up(name)
|
45
|
-
dress_up_quotes(dress_up_slashes(name))
|
46
|
-
end
|
47
|
-
|
48
|
-
#Dress up slashes and backslashes.
|
49
|
-
def dress_up_slashes(name)
|
50
|
-
backslash? ? name.gsub("/", "\\") : name
|
51
|
-
end
|
52
|
-
|
53
|
-
#Dress up in quotes if needed.
|
54
|
-
#<br>Endemic Code Smells
|
55
|
-
#* :reek:UtilityFunction
|
56
|
-
def dress_up_quotes(name)
|
57
|
-
name[' '] ? "\"#{name}\"" : name
|
58
|
-
end
|
59
|
-
|
60
|
-
#Does this file name use backslashes?
|
61
|
-
def backslash?
|
62
|
-
if @pivot.end_with?("\\")
|
63
|
-
true
|
64
|
-
elsif @pivot.end_with?("/")
|
65
|
-
false
|
66
|
-
elsif @pivot["\\"]
|
67
|
-
true
|
68
|
-
elsif @pivot["/"]
|
69
|
-
false
|
70
|
-
else
|
71
|
-
MiniReadline::PLATFORM == :windows
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|