Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8523201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:20:29+00:00 2026-06-11T07:20:29+00:00

The documentation is really vague about subclassing the CommandLineApp, only mentioning one example: class

  • 0

The documentation is really vague about subclassing the CommandLineApp, only mentioning one example:

class YourApp(cli.app.CommandLineApp):
    def main(self):
        do_stuff()

So with the information I’ve found I’ve pieced together this code:

#!/usr/bin/env python

import os
import sys
from cli.app import CommandLineApp

# Append the parent folder to the python path
sys.path.append(os.path.join(os.path.dirname(__file__), '../'))

import tabulardata
from addrtools import extract_address

class SplitAddressApp(CommandLineApp):
    def main(self):
        """
        Split an address from one column to separate columns.
        """

        table = tabulardata.from_file(self.params.file)

        def for_each_row(i, item):
            addr = extract_address(item['Address'])
            print '%-3d %-75s %s' % (i, item['Address'], repr(addr))

        table.each(for_each_row)

    def setup(self):
        self.add_param('file', metavar='FILE', help='The data file.')
        self.add_param(
            'cols', metavar='ADDRESS_COLUMN', nargs='+',
            help='The name of the address column. If multiple names are ' + \
                 'passed, each column will be checked for an address in order'
        )

if __name__ == '__main__':
    SplitAddressApp().run()

Which seems correct to me. The documentation gives no examples on how to handle the setup method or running the application when using subclassing. I get the error:

Traceback (most recent call last):
  File "bin/split_address_column", line 36, in 
    SplitAddressApp().run()
  File "/Users/tomas/.pythonbrew/venvs/Python-2.7.3/address_cleaner/lib/python2.7/site-packages/cli/app.py", line 440, in __init__
    Application.__init__(self, main, **kwargs)
  File "/Users/tomas/.pythonbrew/venvs/Python-2.7.3/address_cleaner/lib/python2.7/site-packages/cli/app.py", line 129, in __init__
    self.setup()
  File "bin/split_address_column", line 28, in setup
    self.add_param('file', metavar='FILE', help='The data file.')
  File "/Users/tomas/.pythonbrew/venvs/Python-2.7.3/address_cleaner/lib/python2.7/site-packages/cli/app.py", line 385, in add_param
    action = self.argparser.add_argument(*args, **kwargs)
AttributeError: 'SplitAddressApp' object has no attribute 'argparser'

So presumably I’m doing something wrong, but what?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:20:31+00:00Added an answer on June 11, 2026 at 7:20 am

    I figured it out. Reading the source of pyCLI it turns out that the setup function is quite important for the functionality of the whole library, while I thought it was just a function where I could put my setup code. argparser is created in cli.app.CommandLineApp.setup which means I at least have to call

    cli.app.CommandLineApp.setup(self)
    

    inside the setup function for it to even work. And now the code works perfectly!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apple really had bad documentation about how the provider connects and communicates to their
I was reading jQuery's documentation about the inArray method and I can't really understand
I'm trying to adopt the Django documentation example on using class based views with
math.h is not really a documentation. Is there something else that will describe these
I've just stumbled upon Fabric and the documentation doesn't really make it obvious how
I'm really confused at the documentation of isSomeFunction , as well as at the
I really like the way Eclipse has pop-up Javadoc documentation for the various Java
As a developer I really don't like writing documentation but when I have to
I'm a new to Prototype and I can't really understand the minimalist documentation provided
The subject says it all, really. Documentation, insofar as it exists at all, suggests

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.