oraora 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: ea908b533f803251dad4a3c654c32da376f4026b
4
- data.tar.gz: 708a8b06e602feaf36619098b5f585d6bed3505a
3
+ metadata.gz: d0525a9154b0f168548f8ba6665cd7e7fc06cf53
4
+ data.tar.gz: 2ad2f0ad89db333bb18a66f7272927174cdbb1cd
5
5
  SHA512:
6
- metadata.gz: d9d0bad778bd145d9244ce38bf32bfba433d6c259bca2669e8666657e2818cd953ca5f5ffae409c446b57da319b6cc8892739a4c2c2d3daefbd5fdc0c8dc64fc
7
- data.tar.gz: 59cc924133dcafbbf68d78b70606a6fb3a3d63122cec05fed7c6a4c29794ab700f61ac1437a2240a02c92681e8d52db658e0e020a7f1b56751e533a14899b2cf
6
+ metadata.gz: 8af2df15ac1afaa55550df03bd388a1af6aeb50ef356c6a87d19ba28e4565f371f0e122dd3c111c2493f21d0e7f4ed498a46a35a03ea91f209cf3e361d602a1f
7
+ data.tar.gz: 8c0d894792da339c2074fd07de15968fa502b8d97f28ebe848ee50dc96cf29facf108f8ab79a3e88c789375ec6eeb09b906c219dafad6abc22c6f7a822b04fb4
data/README.md CHANGED
@@ -23,6 +23,8 @@ If you don't have Ruby, check one-click installer for Windows or rvm for Linux.
23
23
 
24
24
  ## Usage
25
25
 
26
+ ### Connecting to database
27
+
26
28
  Start oraora passing connection string as argument, just like you would connect to SQL*Plus:
27
29
  ```
28
30
  $ oraora user/password@DB
@@ -94,41 +96,68 @@ Note: `l` is aliased as `ls`. `d` is aliased as `desc` and `describe`.
94
96
 
95
97
  ### SQL
96
98
 
97
- Any input starting with SQL keyword like `SELECT`, `INSERT`, `CREATE`, ... is recognized as SQL and passed to database
98
- for execution.
99
+ Any command starting with SQL keyword like `SELECT`, `CREATE`, `ALTER`, etc. is treated as SQL and passed to
100
+ database for execution
101
+
102
+ ```
103
+ ~ $ SELECT * FROM dual;
104
+ D
105
+ -
106
+ X
107
+
108
+ [INFO] 1 row(s) selected
109
+ ```
99
110
 
100
111
  ### Context-aware SQL
101
112
 
102
- When in specific context, you can omit some obvious parts of SQL statements. For example, in context of a table following
103
- statements will work:
113
+ Within specific context, you can omit some obvious keywords or identifiers at the beginning of SQL statements.
114
+ For example, in context of a table following statements will work:
104
115
  ```
105
- ~.SOME_TABLE $ SELECT; # implicit '... FROM SOME_TABLE'
106
- ~.SOME_TABLE $ WHERE col = 1; # implicit 'SELECT * FROM SOME_TABLE ...'
107
- ~.SOME_TABLE $ SET col = 2; # implicit 'UPDATE SOME_TABLE ...'
108
- ~.SOME_TABLE $ ADD x INTEGER; # implicit 'ALTER TABLE SOME_TABLE ...'
116
+ ~.SOME_TABLE $ SELECT; # implicit 'SELECT * FROM SOME_TABLE'
117
+ ~.SOME_TABLE $ WHERE col = 1; # implicit 'SELECT * FROM SOME_TABLE WHERE col = 1'
118
+ ~.SOME_TABLE $ SET col = 2; # implicit 'UPDATE SOME_TABLE SET col = 2'
119
+ ~.SOME_TABLE $ ADD x INTEGER; # implicit 'ALTER TABLE SOME_TABLE ADD x INTEGER'
109
120
  ```
110
121
 
111
122
  Some other examples:
112
123
  ```
113
- ~ $ IDENTIFIED BY oraora; # implicit 'ALTER USER xxx ...'
114
- ~.SOME_TABLE.COL $ WHERE x = 1; # implicit 'SELECT COL FROM SOME_TABLE ...'
124
+ ~ $ IDENTIFIED BY oraora; # implicit 'ALTER USER xxx IDENTIFIED BY oraora'
125
+ ~.SOME_TABLE.COL $ WHERE x = 1; # implicit 'SELECT COL FROM SOME_TABLE WHERE x = 1'
115
126
  ~.SOME_TABLE.COL $ RENAME TO kol; # implicit 'ALTER TABLE SOME_TABLE RENAME COLUMN col TO kol'
116
127
  ```
117
128
 
129
+ ### Tab completion
130
+
131
+ Oraora has bash-style tab completion - hit `<TAB>` to autocomplete current word with SQL keyword or context. If there are
132
+ multiple possible completions hit `<TAB>` twice to see the list.
133
+
134
+ Also there are several quick templates defined. For example, type `S*`, then hit `<TAB>` to expand it into
135
+ `SELECT * FROM `. Available templates are as follows:
136
+
137
+ ```
138
+ s => SELECT
139
+ s* => SELECT * FROM
140
+ c* => SELECT COUNT(*) FROM
141
+ i => INSERT
142
+ u => UPDATE
143
+ d => DELETE
144
+ a => ALTER
145
+ c => CREATE
146
+ cr => CREATE OR REPLACE
147
+ ```
148
+
118
149
  ### Su / sudo
119
150
 
120
151
  `su` and `sudo` allow to switch to SYS session temporarily or execute a single statement as SYS, similarly to their
121
152
  unix counterparts. If you don't have SYS password for current connection in orafile, you will be prompted for it.
122
153
  ```
123
- $ oraora foo@DB
124
- ~ $ SELECT * FROM boo.test;
125
- ERROR: Insufficient privileges
126
- ~ $ sudo GRANT SELECT ON boo.test TO foo;
127
- Grant succeeded.
128
- ~ $ SELECT * FROM boo.test;
129
- text
130
- ------------
131
- Hello world!
154
+ $ oraora test@DB
155
+ ~ $ CREATE TABLE test (a INTEGER);
156
+ [ERROR] ORA-01031: insufficient privileges at 0
157
+ ~ $ sudo GRANT CREATE TABLE TO test;
158
+ [INFO] 0 row(s) affected
159
+ ~ $ CREATE TABLE test (a INTEGER);
160
+ [INFO] 0 row(s) affected
132
161
  ```
133
162
 
134
163
  ## Limitations
data/bin/oraora CHANGED
@@ -8,15 +8,19 @@ begin
8
8
  # Options
9
9
  options = { log_level: Logger::INFO }
10
10
 
11
- OptionParser.new do |opts|
12
- opts.banner = "Usage: oraora [options] connection"
11
+ option_parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: oraora [options] connection_string"
13
13
 
14
14
  opts.on("-l LEVEL", "--log-level=LEVEL", [:debug, :info, :warn, :error], "Set message verbosity (debug, info, warn, error)") do |l|
15
15
  options[:log_level] = Logger.const_get(l.upcase)
16
16
  end
17
17
 
18
18
  opts.on("-h", "--help", "Show this message") { |h| puts opts; exit }
19
- end.parse!
19
+ end
20
+ option_parser.parse!
21
+
22
+ # Check arguments
23
+ raise ArgumentError if ARGV.length == 0
20
24
 
21
25
  # Logger
22
26
  logger = Oraora::Logger.new(STDOUT, options[:log_level])
@@ -39,6 +43,9 @@ begin
39
43
  rescue OptionParser::ParseError => e
40
44
  puts "Options error: " + e.message
41
45
 
46
+ rescue ArgumentError
47
+ puts option_parser.help
48
+
42
49
  rescue Oraora::Credentials::ParseError => e
43
50
  puts "Invalid connection string: " + e.message
44
51
 
@@ -1,3 +1,4 @@
1
+
1
2
  module Oraora
2
3
  class App
3
4
  class InvalidCommand < StandardError; end
@@ -14,7 +15,7 @@ module Oraora
14
15
  USER SESSION SCHEMA SYSTEM DATABASE
15
16
  REPLACE AND OR
16
17
  )
17
- ORAORA_KEYWORDS = %w(c cd l ls d desc describe x exit su sudo - -- --- . ! /)
18
+ ORAORA_KEYWORDS = %w(c cd l ls d desc describe x exit su sudo - -- --- . ! ? /)
18
19
 
19
20
  attr_reader :meta, :context
20
21
 
@@ -32,6 +33,7 @@ module Oraora
32
33
  # Connect to Oracle
33
34
  @logger.debug "Connecting: #{@credentials}" + (@role ? " as #{@role}" : '')
34
35
  logon
36
+ @logger.info "Oraora v#{VERSION}. Type '?' for quick help"
35
37
  @user ||= @oci.username
36
38
  @context ||= Context.new(@user, schema: @user)
37
39
 
@@ -73,7 +75,7 @@ module Oraora
73
75
 
74
76
  rescue Interrupt
75
77
  if Time.now - last_interrupt < 2
76
- @logger.warn "Exit on CTRL+C, "
78
+ @logger.warn "Exit on CTRL+C"
77
79
  terminate
78
80
  else
79
81
  @logger.warn "CTRL+C, hit again within 2 seconds to quit"
@@ -237,6 +239,10 @@ module Oraora
237
239
  @logger.debug "Command type: metadata refresh"
238
240
  @meta.purge_cache
239
241
 
242
+ when '?'
243
+ @logger.debug "Command type: help"
244
+ puts(HELP)
245
+
240
246
  # Unknown
241
247
  else
242
248
  raise InvalidCommand, "Invalid command: #{$1}"
@@ -0,0 +1,23 @@
1
+ require 'oraora/completion'
2
+
3
+ module Oraora
4
+ HELP = <<-HERE.reset_indentation
5
+ Oraora v#{VERSION} - https://github.com/kmehkeri/oraora
6
+
7
+ Commands reference:
8
+ c / cd [path]- Change context (or home schema if path not provided)
9
+ l / ls [path] List in path (or current context)
10
+ d / desc / describe Describe path (or current context)
11
+ x / exit Exit
12
+ sudo [command] Execute a single command as SYS
13
+ su Spawn a subshell using SYS username
14
+ - / -- / --- Navigate 1/2/3 levels up
15
+ . Navigate to database root
16
+ ! Refresh metadata
17
+ ? Display this help
18
+ SELECT ... or any other SQL keyword - execute
19
+
20
+ Quick templates (type then press <TAB> to expand):
21
+ #{Completion::TEMPLATES.collect { |template, expansion| "%-3s => %s" % [template, expansion] }.join("\n ")}
22
+ HERE
23
+ end
@@ -0,0 +1,3 @@
1
+ module Oraora
2
+ VERSION = '0.1.1'
3
+ end
@@ -1,22 +1,27 @@
1
+ require './lib/oraora/version'
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'oraora'
3
- s.version = '0.1.0'
5
+ s.version = Oraora::VERSION
4
6
  s.summary = "Interactive command-line utility for Oracle"
5
- s.description = "Interactive command-line utility for Oracle"
7
+ s.description = <<-EOS
8
+ SQL*Plus replacement for interactive work with Oracle, with tab-completion, colored output,
9
+ metadata navigation with context-aware SQL and more features
10
+ EOS
6
11
 
7
12
  s.author = "kmehkeri"
8
13
  s.email = 'kmehkeri@gmail.com'
9
- s.homepage = 'http://rubygems.org/gems/oraora'
14
+ s.homepage = 'https://github.com/kmehkeri/oraora'
10
15
  s.license = 'MIT'
11
16
 
12
17
  s.files = `git ls-files`.split($/)
13
18
  s.executables = `git ls-files -- bin`.split($/).map { |f| File.basename(f) }
14
19
 
15
- s.add_runtime_dependency 'highline'
16
- s.add_runtime_dependency 'ruby-oci8'
17
- s.add_runtime_dependency 'indentation'
18
- s.add_runtime_dependency 'colorize'
19
- s.add_runtime_dependency 'bigdecimal'
20
+ s.add_runtime_dependency 'highline', '~> 1'
21
+ s.add_runtime_dependency 'ruby-oci8', '~> 2'
22
+ s.add_runtime_dependency 'indentation', '~> 0'
23
+ s.add_runtime_dependency 'colorize', '~> 0'
24
+ s.add_runtime_dependency 'bigdecimal', '~> 1'
20
25
 
21
- s.add_development_dependency 'rspec'
26
+ s.add_development_dependency 'rspec', '~> 3'
22
27
  end
metadata CHANGED
@@ -1,107 +1,109 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oraora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kmehkeri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-25 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-oci8
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: indentation
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: colorize
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bigdecimal
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '3'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
97
- description: Interactive command-line utility for Oracle
96
+ version: '3'
97
+ description: |2
98
+ SQL*Plus replacement for interactive work with Oracle, with tab-completion, colored output,
99
+ metadata navigation with context-aware SQL and more features
98
100
  email: kmehkeri@gmail.com
99
101
  executables:
100
102
  - oraora
101
103
  extensions: []
102
104
  extra_rdoc_files: []
103
105
  files:
104
- - .gitignore
106
+ - ".gitignore"
105
107
  - LICENSE
106
108
  - README.md
107
109
  - bin/oraora
@@ -111,6 +113,7 @@ files:
111
113
  - lib/oraora/completion.rb
112
114
  - lib/oraora/context.rb
113
115
  - lib/oraora/credentials.rb
116
+ - lib/oraora/help.rb
114
117
  - lib/oraora/logger.rb
115
118
  - lib/oraora/meta.rb
116
119
  - lib/oraora/meta/column.rb
@@ -124,10 +127,11 @@ files:
124
127
  - lib/oraora/meta/view.rb
125
128
  - lib/oraora/oci.rb
126
129
  - lib/oraora/terminal.rb
130
+ - lib/oraora/version.rb
127
131
  - oraora.gemspec
128
132
  - spec/context_spec.rb
129
133
  - spec/credentials_spec.rb
130
- homepage: http://rubygems.org/gems/oraora
134
+ homepage: https://github.com/kmehkeri/oraora
131
135
  licenses:
132
136
  - MIT
133
137
  metadata: {}
@@ -137,17 +141,17 @@ require_paths:
137
141
  - lib
138
142
  required_ruby_version: !ruby/object:Gem::Requirement
139
143
  requirements:
140
- - - '>='
144
+ - - ">="
141
145
  - !ruby/object:Gem::Version
142
146
  version: '0'
143
147
  required_rubygems_version: !ruby/object:Gem::Requirement
144
148
  requirements:
145
- - - '>='
149
+ - - ">="
146
150
  - !ruby/object:Gem::Version
147
151
  version: '0'
148
152
  requirements: []
149
153
  rubyforge_project:
150
- rubygems_version: 2.1.11
154
+ rubygems_version: 2.4.5
151
155
  signing_key:
152
156
  specification_version: 4
153
157
  summary: Interactive command-line utility for Oracle