Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78900

Re: CLI framework using python

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'url:pypi': 0.03; 'framework.': 0.09; 'params': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:using': 0.09; 'python': 0.11; 'suggest': 0.14; '2.7': 0.14; '(something': 0.16; 'cli': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'scripts.': 0.16; 'subject:python': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'slightly': 0.19; 'thu,': 0.19; 'examples': 0.20; 'example': 0.22; 'header:User-Agent:1': 0.23; 'script': 0.25; 'pass': 0.26; 'downloaded': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'installed': 0.27; 'appreciated.': 0.29; 'unix': 0.29; "doesn't": 0.30; 'newer': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'figure': 0.32; 'url:python': 0.33; 'framework': 0.33; 'received:fr': 0.33; "i'd": 0.34; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'executing': 0.36; 'url:listinfo': 0.36; "didn't": 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; "couldn't": 0.39; 'guidance': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:mail': 0.40; 'how': 0.40; 'commands': 0.60; 'address': 0.63; 'such': 0.63; 'grab': 0.64; 'charset:windows-1252': 0.65; 'within': 0.65; 'received:109': 0.72; 'lack': 0.78; 'forward.': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Gelonida N <gelonida@gmail.com>
Subject Re: CLI framework using python
Date Thu, 09 Oct 2014 18:00:57 +0200
References <274771d2-4a11-40fe-bc31-ccfaa7d32690@googlegroups.com> <CACDG_KeytO8LV0yfGQ+nx+tRTTLd=64CwCwdsYnE=pdMsf0Z9w@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 1-75-190-109.dsl.ovh.fr
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2
In-Reply-To <CACDG_KeytO8LV0yfGQ+nx+tRTTLd=64CwCwdsYnE=pdMsf0Z9w@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14720.1412870470.18130.python-list@python.org> (permalink)
Lines 73
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1412870470 news.xs4all.nl 2833 [2001:888:2000:d::a6]:54330
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78900

Show key headers only | View raw


On 10/09/2014 05:25 PM, Unix SA wrote:
> Hello,
>
> Go for Optparse.. Look at below docs on how to use it.
>
> http://pymotw.com/2/optparse/
>

For newer projects I'd suggest argparse (part of Python since 2.7 and 
can be downloaded / installed for 2.5 / 2.6).

https://docs.python.org/2.7/library/argparse.html

argparse is very powerfull. you might be interested in looking at 
subparsers.


For calling commands in a slightly nicer way than os.system / 
sybprocess.Popen you might look at sh or plumbum

https://pypi.python.org/pypi/sh

https://pypi.python.org/pypi/plumbum



> Regards,
> DJ
>
> On Thu, Oct 9, 2014 at 5:50 PM, <vijnaana@gmail.com
> <mailto:vijnaana@gmail.com>> wrote:
>
>     Hi,
>
>     I need to develop a python CLI framework.
>
>     For example if i need to set an ip address in linux:
>
>     ifconfig eth0 172.16.25.125
>
>     I should be able to use python to do the above.
>
>     1. The user will execute a python script to which i will pass the
>     params eth0 and ip address (something like ifconf.py  eth0
>     172.16.25.125)
>
>     2. Within the script i grab the params and do something to the
>     effect of user executing 'ifconfig eth0 172.16.25.125' from the shell.
>
>     3. There are other such commands for which i will be using python
>     scripts. I came across pyCLI, but it doesn't have much
>     documentation, so couldn't figure out how to move forward.
>
>     4. The CLI framework needs to reuse code so i didn't want to use
>     pure python and develop a framework from scratch. Rather use
>     something like pyCLI/CLIFF.
>
>     The problem is lack of documentation with examples on how to use the
>     above.
>
>     Any guidance would be greatly appreciated.
>
>     Regards & Thanks,
>     Vij
>
>     --
>     https://mail.python.org/mailman/listinfo/python-list
>
>
>
>

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

CLI framework using python vijnaana@gmail.com - 2014-10-09 05:20 -0700
  Re: CLI framework using python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-09 09:07 -0400
  Re: CLI framework using python Unix SA <d.joshi84@gmail.com> - 2014-10-09 20:55 +0530
  Re: CLI framework using python Gelonida N <gelonida@gmail.com> - 2014-10-09 18:00 +0200
    Re: CLI framework using python Rustom Mody <rustompmody@gmail.com> - 2014-10-10 01:43 -0700
      Re: CLI framework using python Gelonida N <gelonida@gmail.com> - 2014-10-10 13:58 +0200
  Re: CLI framework using python Python UL <python@rgbaz.eu> - 2014-10-09 18:08 +0200
  Re: CLI framework using python vijnaana bhairava <vijnaana@gmail.com> - 2014-10-14 06:33 -0700
    Re: CLI framework using python Chris Angelico <rosuav@gmail.com> - 2014-10-15 00:43 +1100
    Re: CLI framework using python "Naoki INADA" <songofacandy@gmail.com> - 2014-10-14 07:15 -0700
      Re: CLI framework using python vijnaana bhairava <vijnaana@gmail.com> - 2014-10-15 09:05 -0700

csiph-web