db2c 0.0.2 → 0.0.3

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.
data/bin/db2c CHANGED
@@ -10,28 +10,10 @@ if !ARGV.include?('--no-rlwrap') && !system("which rlwrap > /dev/null 2> /dev/nu
10
10
  exit
11
11
  end
12
12
 
13
- def show_help
14
- puts <<-help
15
- Usage: db2c
16
-
17
- Options:
18
- --help Display this message
19
- --man Display the man page
20
-
21
- Bug reports, suggestions, updates: http://github.com/on-site/db2c
22
- help
23
- exit
24
- end
25
-
26
- if ARGV.any? { |arg| %w( -h --help -help help ).include?(arg) }
27
- show_help
28
- end
29
-
30
13
  cdir = File.dirname(__FILE__)
31
- if ARGV.include? '--man'
14
+ unless (ARGV & %w{h help -help --help --man}).empty?
32
15
  exec "man #{cdir}/../man/db2c.1"
33
16
  end
34
-
35
17
  unless ARGV.include? '--no-rlwrap'
36
18
  exec "rlwrap -z pipeto -i -r -s 999999 -pBLUE -f #{cdir}/ac -H ~/.db2c_history db2c --no-rlwrap #{ARGV.join(' ')}"
37
19
  end
@@ -39,7 +21,7 @@ end
39
21
  $LOAD_PATH.unshift 'lib'
40
22
  require "db2c"
41
23
 
42
- Db2c::Command.debug = ARGV.any? { |arg| %w( -d --debug -debug debug ).include?(arg) }
24
+ Db2c::Command.debug = !(ARGV & %w{ -d --debug -debug debug }).empty?
43
25
 
44
26
  loop do
45
27
  print Db2c::Command.prompt
data/lib/db2c.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Db2c
2
2
  DEFAULT_PROMPT = "db2c => "
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
 
6
6
  require "db2c/command.rb"
data/lib/db2c/command.rb CHANGED
@@ -35,6 +35,9 @@ module Db2c
35
35
  if @input =~ /^connect to (.*)$/i
36
36
  @@cdb = $1.downcase
37
37
  end
38
+ if @input =~ /^disconnect #{@@cdb}$/i || @input =~ /^connect reset$/i
39
+ @@cdb = ''
40
+ end
38
41
  end
39
42
 
40
43
  def self.debug=(value)
data/man/db2c.1 CHANGED
@@ -7,38 +7,88 @@
7
7
  \fBdb2c\fR \- a db2 console with with history and autocomplete support
8
8
  .
9
9
  .SH "SYNOPSIS"
10
- \fBdb2c\fR \fI\fIoptions\fR\fR <\.\.\.>
10
+ \fBdb2c\fR \fI\fIoptions\fR\fR
11
11
  .
12
- .SH "DESCRIPTION"
12
+ .SH "DESCRIPTION && EXAMPLES"
13
13
  DB2 console mode does not support readline and autocomplete, this is a wrapper for the db2 command with support for both\.
14
14
  .
15
- .SH "EXAMPLES"
15
+ .TP
16
+ \fBHistory\fR
17
+ .
18
+ .IP "" 4
19
+ .
20
+ .nf
21
+
22
+
23
+ db2 => connect to testdb (or: db2 => use testdb)
24
+ db2(testdb) => current date
25
+ db2(testdb) => \-107
26
+ (Use the arrows for history, you can also use \fICTRL\fR\-r to search the history)
27
+ .
28
+ .fi
29
+ .
30
+ .IP "" 0
31
+
32
+ .
33
+ .TP
34
+ \fBAutocomplete\fR
35
+ .
36
+ .IP "" 4
37
+ .
38
+ .nf
39
+
40
+
41
+ db2(testdb) => sel[double\-tab]
42
+ it remembers\.\.
43
+ db2(testdb) => list tables for schema xyz
44
+ db2(testdb) => select * from xyz\.tab[double\-tab]
45
+ .
46
+ .fi
47
+ .
48
+ .IP "" 0
49
+
50
+ .
51
+ .TP
52
+ \fBYou can pipe\fR
53
+ .
54
+ .IP "" 4
16
55
  .
17
56
  .nf
18
57
 
19
- $ db2c
20
- db2 => connect to testdb
21
- or: db2 => use testdb
22
- db2 => current date
23
- db2 => \-107
24
58
 
25
- Use the arrows for history, you can also use <CTRL>\-r to search the history
59
+ db2(testdb) => select * from large\.table | grep \-v something
60
+ db2(testdb) => select * from large\.table | less
61
+ .
62
+ .fi
63
+ .
64
+ .IP "" 0
65
+
66
+ .
67
+ .TP
68
+ If a command outputs long lines, you can use \fBless \-S\fR
69
+ .
70
+ .IP "" 4
71
+ .
72
+ .nf
73
+
26
74
 
27
- You can pipe:
28
- db2 => select * from large\.table | less
29
- db2 => select * from large\.table | grep something
75
+ db2(testdb) => select * from table\.with\.many\.columns | less \-S
76
+ (you can scorll horizontally with left/right arrows)
30
77
  .
31
78
  .fi
79
+ .
80
+ .IP "" 0
81
+
32
82
  .
33
83
  .SH "OPTIONS"
34
84
  .
35
85
  .TP
36
- \fB\-h\fR, \fB\-\-help\fR
37
- Displays usage information\.
86
+ \fB\-h\fR, \fB\-\-help\fR, \fB\-\-man\fR
87
+ Displays this help page\.
38
88
  .
39
89
  .TP
40
- \fB\-\-man\fR
41
- Displays this man page\.
90
+ \fB\-\-debug\fR
91
+ Displays annoying messages\.
42
92
  .
43
93
  .SH "BUGS"
44
94
  \fIhttp://github\.com/on\-site/db2c/issues\fR
data/man/db2c.1.html CHANGED
@@ -55,8 +55,7 @@
55
55
  <div class='man-navigation' style='display:none'>
56
56
  <a href="#NAME">NAME</a>
57
57
  <a href="#SYNOPSIS">SYNOPSIS</a>
58
- <a href="#DESCRIPTION">DESCRIPTION</a>
59
- <a href="#EXAMPLES">EXAMPLES</a>
58
+ <a href="#DESCRIPTION-EXAMPLES">DESCRIPTION &amp;&amp; EXAMPLES</a>
60
59
  <a href="#OPTIONS">OPTIONS</a>
61
60
  <a href="#BUGS">BUGS</a>
62
61
  <a href="#AUTHOR">AUTHOR</a>
@@ -76,32 +75,41 @@
76
75
 
77
76
  <h2 id="SYNOPSIS">SYNOPSIS</h2>
78
77
 
79
- <p><code>db2c</code> <var><a href="#OPTIONS" title="OPTIONS" data-bare-link="true">options</a></var> &lt;...></p>
78
+ <p><code>db2c</code> <var><a href="#OPTIONS" title="OPTIONS" data-bare-link="true">options</a></var></p>
80
79
 
81
- <h2 id="DESCRIPTION">DESCRIPTION</h2>
80
+ <h2 id="DESCRIPTION-EXAMPLES">DESCRIPTION &amp;&amp; EXAMPLES</h2>
82
81
 
83
82
  <p>DB2 console mode does not support readline and autocomplete, this is a wrapper for the db2 command with support for both.</p>
84
83
 
85
- <h2 id="EXAMPLES">EXAMPLES</h2>
86
-
87
- <pre><code>$ db2c
88
- db2 =&gt; connect to testdb
89
- or: db2 =&gt; use testdb
90
- db2 =&gt; current date
91
- db2 =&gt; -107
92
-
93
- Use the arrows for history, you can also use &lt;CTRL>-r to search the history
84
+ <dl>
85
+ <dt class="flush"><strong>History</strong></dt><dd><p></p><pre>
86
+ db2 => connect to testdb (or: db2 => use testdb)
87
+ db2(testdb) => current date
88
+ db2(testdb) => -107
89
+ (Use the arrows for history, you can also use <var>CTRL</var>-r to search the history)
90
+ </pre></dd>
91
+ <dt><strong>Autocomplete</strong></dt><dd><p></p><pre>
92
+ db2(testdb) => sel[double-tab]
93
+ it remembers..
94
+ db2(testdb) => list tables for schema xyz
95
+ db2(testdb) => select * from xyz.tab[double-tab]
96
+ </pre></dd>
97
+ <dt><strong>You can pipe</strong></dt><dd><p></p><pre>
98
+ db2(testdb) => select * from large.table | grep -v something
99
+ db2(testdb) => select * from large.table | less
100
+ </pre></dd>
101
+ <dt>If a command outputs long lines, you can use <strong>less -S</strong></dt><dd><p></p><pre>
102
+ db2(testdb) => select * from table.with.many.columns | less -S
103
+ (you can scorll horizontally with left/right arrows)
104
+ </pre></dd>
105
+ </dl>
94
106
 
95
- You can pipe:
96
- db2 =&gt; select * from large.table | less
97
- db2 =&gt; select * from large.table | grep something
98
- </code></pre>
99
107
 
100
108
  <h2 id="OPTIONS">OPTIONS</h2>
101
109
 
102
110
  <dl>
103
- <dt><code>-h</code>, <code>--help</code></dt><dd><p>Displays usage information.</p></dd>
104
- <dt class="flush"><code>--man</code></dt><dd><p>Displays this man page.</p></dd>
111
+ <dt><code>-h</code>, <code>--help</code>, <code>--man</code></dt><dd><p>Displays this help page.</p></dd>
112
+ <dt class="flush"><code>--debug</code></dt><dd><p>Displays annoying messages.</p></dd>
105
113
  </dl>
106
114
 
107
115
 
@@ -111,7 +119,7 @@ db2 =&gt; select * from large.table | grep something
111
119
 
112
120
  <h2 id="AUTHOR">AUTHOR</h2>
113
121
 
114
- <p>Samer Abukhait <a href="&#x6d;&#97;&#105;&#108;&#x74;&#x6f;&#58;&#x73;&#97;&#109;&#x65;&#114;&#64;&#111;&#x6e;&#45;&#115;&#x69;&#116;&#101;&#78;&#x4f;&#83;&#80;&#65;&#77;&#x2e;&#99;&#x6f;&#109;" data-bare-link="true">&#x73;&#97;&#109;&#x65;&#x72;&#x40;&#x6f;&#x6e;&#45;&#x73;&#x69;&#x74;&#x65;&#x4e;&#x4f;&#83;&#x50;&#65;&#x4d;&#x2e;&#99;&#111;&#109;</a>, @s4mer</p>
122
+ <p>Samer Abukhait <a href="&#109;&#97;&#x69;&#108;&#x74;&#x6f;&#58;&#x73;&#x61;&#109;&#101;&#114;&#64;&#x6f;&#110;&#x2d;&#115;&#105;&#x74;&#101;&#x4e;&#79;&#83;&#x50;&#x41;&#77;&#46;&#99;&#x6f;&#x6d;" data-bare-link="true">&#115;&#97;&#x6d;&#x65;&#114;&#64;&#111;&#110;&#45;&#x73;&#105;&#116;&#101;&#x4e;&#x4f;&#83;&#80;&#x41;&#77;&#x2e;&#x63;&#x6f;&#109;</a>, @s4mer</p>
115
123
 
116
124
  <h2 id="SEE-ALSO">SEE ALSO</h2>
117
125
 
data/man/db2c.1.ronn CHANGED
@@ -3,33 +3,47 @@ db2c(1) - a db2 console with with history and autocomplete support
3
3
 
4
4
  ## SYNOPSIS
5
5
 
6
- `db2c` <[options]> <...>
6
+ `db2c` <[options]>
7
7
 
8
- ## DESCRIPTION
8
+ ## DESCRIPTION && EXAMPLES
9
9
 
10
10
  DB2 console mode does not support readline and autocomplete, this is a wrapper for the db2 command with support for both.
11
11
 
12
- ## EXAMPLES
13
-
14
- $ db2c
15
- db2 => connect to testdb
16
- or: db2 => use testdb
17
- db2 => current date
18
- db2 => -107
19
-
20
- Use the arrows for history, you can also use <CTRL>-r to search the history
21
-
22
- You can pipe:
23
- db2 => select * from large.table | less
24
- db2 => select * from large.table | grep something
12
+ * **History**:
13
+ <pre>
14
+ db2 => connect to testdb (or: db2 => use testdb)
15
+ db2(testdb) => current date
16
+ db2(testdb) => -107
17
+ (Use the arrows for history, you can also use <CTRL>-r to search the history)
18
+ </pre>
19
+
20
+ * **Autocomplete**:
21
+ <pre>
22
+ db2(testdb) => sel[double-tab]
23
+ it remembers..
24
+ db2(testdb) => list tables for schema xyz
25
+ db2(testdb) => select * from xyz.tab[double-tab]
26
+ </pre>
27
+
28
+ * **You can pipe**:
29
+ <pre>
30
+ db2(testdb) => select * from large.table | grep -v something
31
+ db2(testdb) => select * from large.table | less
32
+ </pre>
33
+
34
+ * If a command outputs long lines, you can use **less -S**:
35
+ <pre>
36
+ db2(testdb) => select * from table.with.many.columns | less -S
37
+ (you can scorll horizontally with left/right arrows)
38
+ </pre>
25
39
 
26
40
  ## OPTIONS
27
41
 
28
- * `-h`, `--help`:
29
- Displays usage information.
42
+ * `-h`, `--help`, `--man`:
43
+ Displays this help page.
30
44
 
31
- * `--man`:
32
- Displays this man page.
45
+ * `--debug`:
46
+ Displays annoying messages.
33
47
 
34
48
  ## BUGS
35
49
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db2c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: