[Montreal-pm] building command line interfaces
Olivier Bilodeau
obilodeau at inverse.ca
Mer 29 Fév 19:37:11 PST 2012
Hi,
I'm looking for a module that does pretty command line interfaces. It
does not need to be interactive and I would prefer if it would be simple.
It's for yet-another-of-Olivier's-open-source-project: dhcp0f[1].
I know there is perl's "formats"[1] but I remember reading something
like: avoid this at all cost.. Or was it even Larry that said himself
that he wasn't proud of that..?
Anyways, the data is like:
> 2012-02-29 22:03:43
> --------------------------------------------------------------------------------
> Ethernet src: 00:15:af:xx:xx:xx dst: ff:ff:ff:ff:ff:ff
> IP src: 0.0.0.0 dst: 255.255.255.255
> UDP src port: 68 dst port: 67
> --------------------------------------------------------------------------------
> DHCPREQUEST from 0.0.0.0 (00:15:af:xx:xx:xx)
> requested ip address: 192.168.0.192
> message type: 3
> hostname: bt
> requested parameter list: 1,28,2,3,15,6,12
> dhcp server id: 192.168.0.1
> TTL: 128
> DHCP fingerprint: 1,28,2,3,15,6,12
> OS / Device Identification: Debian-based Linux
> ================================================================================
> ^C
> ================================================================================
> | Summary of DHCP clients encountered |
> ================================================================================
> 00:15:af:xx:xx:xx 192.168.0.192 Debian-based Linux 1,28,2,3,15,6,12 None
> 00:15:af:xx:xx:xx 192.168.0.192 Debian-based Linux 1,28,2,3,15,6,12 None
> ================================================================================
The header between rows of -----, are actually hardcoded with printf's
but for the summary table it won't be as easy as I don't know how long
the digit strings will be and it could be really long! So something that
would detect shell's width and maybe shorten if it knows it won't fit
would be really nice!
On my radar:
- Text::ASCIITable
Any other suggestions I overlooked? Is perlform really not recommended?
[1]: perldoc perlform
[2]: https://github.com/inverse-inc/dhcp0f
--
Olivier Bilodeau
obilodeau at inverse.ca :: +1.514.447.4918 *115 :: www.inverse.ca
Inverse inc. :: Leaders behind SOGo (www.sogo.nu) and PacketFence
(www.packetfence.org)
Plus d'informations sur la liste de diffusion Montreal-pm