Comments (6)
This issue is main
does not return a click
object. You need to modify it like so.
diff --git a/mycli.py b/mycli.py
index 0b87781..fb3afb4 100644
--- a/mycli.py
+++ b/mycli.py
@@ -16,9 +16,7 @@ def test_command():
"""
click.echo("Hello world")
-def main():
- mycli.add_command(test_command)
- mycli()
+mycli.add_command(test_command)
if __name__ == '__main__':
- main()
+ mycli()
diff --git a/setup.py b/setup.py
index 2afc564..20a85e7 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ setup(
install_requires=['click'],
entry_points='''
[console_scripts]
- my=mycli:main
+ my=mycli:mycli
''',
classifiers=[
'Natural Language :: English',
This ensures that (a) the add_command
function is always called and the command registered and (b) you're trying to document a click
object and not a random function.
from click-man.
We saw a similar issue with https://github.com/click-contrib/sphinx-click. tl;dr: you're using the wrong configuration. See click-contrib/sphinx-click#13
from click-man.
Which configuration?
from click-man.
Which configuration?
The commands listed in your console_scripts
setting in conf.py
. Have you a minimal test case you can share?
from click-man.
Sure, here is the test case:
mycli.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import click
@click.group()
def mycli():
"""
Test CLI
"""
pass
@click.command()
def test_command():
"""
This is a test command
"""
click.echo("Hello world")
def main():
mycli.add_command(test_command)
mycli()
if __name__ == '__main__':
main()
setup.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
setup(
name='MyCLI',
py_modules=['mycli'],
packages=find_packages(),
install_requires=['click'],
entry_points='''
[console_scripts]
my=mycli:main
''',
classifiers=[
'Natural Language :: English',
'Operating System :: Microsoft :: Windows',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python'
]
)
Executed command:
$ PATH=env/bin/ click-man my
Load entry point my
Generate man pages for my in /home/elie/Documents/git/mycli/man
Traceback (most recent call last):
File "env/bin//click-man", line 11, in <module>
sys.exit(cli())
File "/home/elie/Documents/git/mycli/env/lib/python2.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/home/elie/Documents/git/mycli/env/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/elie/Documents/git/mycli/env/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/elie/Documents/git/mycli/env/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/elie/Documents/git/mycli/env/lib/python2.7/site-packages/click_man/__main__.py", line 49, in cli
write_man_pages(name, cli, version=entry_point.dist.version, target_dir=target)
File "/home/elie/Documents/git/mycli/env/lib/python2.7/site-packages/click_man/core.py", line 54, in write_man_pages
ctx = click.Context(cli, info_name=name, parent=parent_ctx)
File "/home/elie/Documents/git/mycli/env/lib/python2.7/site-packages/click/core.py", line 254, in __init__
allow_extra_args = command.allow_extra_args
AttributeError: 'function' object has no attribute 'allow_extra_args'
from click-man.
It works! Many thanks
from click-man.
Related Issues (20)
- How to generate man pages for each entry point ? HOT 2
- Generating portable manpages HOT 8
- Sub-commands manual not generated HOT 2
- Remove dependency on disutils Command? HOT 1
- Upload 0.2.2 to PyPI HOT 1
- Missing docstring raises cryptic error HOT 2
- use click 7.0 Generate man pages report "AttributeError" HOT 1
- Use Jinja2 for base man page
- Man pages are generated for 'hidden' commands.
- Description on PyPI isn't formatted correctly HOT 2
- Formatted text in help text not rendered properly
- RFE: Be able to disable inclusion of date in generated manpage
- 0.4.0 release tarball naming, contents irregularity HOT 3
- Feature switches are not handled correctly
- Use unclear in non setuptools project HOT 2
- Add support for typer applications HOT 1
- Not reading dynamically added commands
- man page format broken in debian 12 HOT 1
- Man pages ignore \b characters in docstrings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from click-man.