M
Michael 'entropie' Trommer
--6zdv2QT/q3FMhpsV
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello,
I use [1] to process a string from cmdline-user-input to call methods
form a module namespace. It works for
now, but there are later a lot of commands to input so i want
tab-completion because iam lazy
module CmdsBase
CmdsBase.cmd_foo
DoSomething.new
end
...
end
All methods with /^cmd_(\w*)$/ should be completeable from
commandline.
Any ideas to solve this clean?
[1]
# snip:
def self.cmd
begin
line = gets
args, i =[], -1
line.scan(/\w*\s/) do |a|
a.strip!
meth = nil
unless (i+=1).zero? and
MyBiadjCmdlineCaller.methods.include?(a)
break if i.zero?
args.push(a)
else
meth = a
end
unless args.size.zero? # ignoring input with arguments yet
MyBiadjCMDLine.ok?(MyBiadjCmdlineCaller.method(meth).call)
end
end
end while true
end
So long
--
Michael 'entropie' Trommer; http://ackro.org
ruby -e "0.upto((a='njduspAhnbjm/dpn').size-1){|x| a[x]-=1}; p 'mailto:'+a"
--6zdv2QT/q3FMhpsV
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFDrP6BBBd8ye5RguQRAuBiAJ49CspQM2fc3IqdrYbCviChm9AzZACgxJPk
VUPKSQ1rU6sg45DphcL2Krs=
=Z+ob
-----END PGP SIGNATURE-----
--6zdv2QT/q3FMhpsV--
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello,
I use [1] to process a string from cmdline-user-input to call methods
form a module namespace. It works for
now, but there are later a lot of commands to input so i want
tab-completion because iam lazy
module CmdsBase
CmdsBase.cmd_foo
DoSomething.new
end
...
end
All methods with /^cmd_(\w*)$/ should be completeable from
commandline.
Any ideas to solve this clean?
[1]
# snip:
def self.cmd
begin
line = gets
args, i =[], -1
line.scan(/\w*\s/) do |a|
a.strip!
meth = nil
unless (i+=1).zero? and
MyBiadjCmdlineCaller.methods.include?(a)
break if i.zero?
args.push(a)
else
meth = a
end
unless args.size.zero? # ignoring input with arguments yet
MyBiadjCMDLine.ok?(MyBiadjCmdlineCaller.method(meth).call)
end
end
end while true
end
So long
--
Michael 'entropie' Trommer; http://ackro.org
ruby -e "0.upto((a='njduspAhnbjm/dpn').size-1){|x| a[x]-=1}; p 'mailto:'+a"
--6zdv2QT/q3FMhpsV
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFDrP6BBBd8ye5RguQRAuBiAJ49CspQM2fc3IqdrYbCviChm9AzZACgxJPk
VUPKSQ1rU6sg45DphcL2Krs=
=Z+ob
-----END PGP SIGNATURE-----
--6zdv2QT/q3FMhpsV--