Skip to content

Commit

Permalink
Automatic deploy (build number 9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ConanCI bot committed Feb 21, 2024
1 parent 9584014 commit 9d2a72e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 16 deletions.
15 changes: 11 additions & 4 deletions 2.1/_sources/reference/extensions/custom_commands.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,14 @@ Commands can define their own arguments with the ``argparse`` Python library.
Command help
"""
parser.add_argument("path", nargs="?", help='help for command')
add_reference_args(parser)
...
args = parser.parse_args(*args)
# Use args.path
When there are sub-commands, the base command cannot define arguments, only the sub-commands can do it. If you have a set of common arguments to all sub-commands, you can define a function that adds them.
When there are sub-commands, the base command cannot define arguments, only the
sub-commands can do it. If you have a set of common arguments to all sub-commands, you can
define a function that adds them.

.. code-block:: python
Expand Down Expand Up @@ -243,8 +245,13 @@ These are the passed arguments to any custom command and its sub-commands functi
Normally, they'll be parsed as ``args = parser.parse_args(*args)``. For instance, running :command:`conan mycommand arg1 arg2 arg3`,
the command function will receive them as a Python list-like ``["arg1", "arg2", "arg3"]``.


Read more
---------

- :ref:`Custom command to remove recipe and package revisions but the latest package one from the latest recipe one<examples_extensions_commands_clean_revisions>`.
- :ref:`Custom command to remove recipe and package revisions but the latest package one
from the latest recipe one<examples_extensions_commands_clean_revisions>`.
- You can check more examples of Conan custom command in the *conan-extensions* repository.
There you can find examples of custom commands without sub-commands `like this one
<https://github.com/conan-io/conan-extensions/blob/main/extensions/commands/art/cmd_server.py>`__.
and custom commands with sub-commands `like this one
<https://github.com/conan-io/conan-extensions/blob/main/extensions/commands/cci/cmd_export_all_versions.py>`__.
Binary file modified 2.1/conan.pdf
Binary file not shown.
12 changes: 9 additions & 3 deletions 2.1/reference/extensions/custom_commands.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,14 @@ <h2>Argument definition and parsing<a class="headerlink" href="#argument-definit
<span class="sd"> Command help</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;path&quot;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s2">&quot;?&quot;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;help for command&#39;</span><span class="p">)</span>
<span class="n">add_reference_args</span><span class="p">(</span><span class="n">parser</span><span class="p">)</span>
<span class="o">...</span>
<span class="n">args</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
<span class="c1"># Use args.path</span>
</pre></div>
</div>
<p>When there are sub-commands, the base command cannot define arguments, only the sub-commands can do it. If you have a set of common arguments to all sub-commands, you can define a function that adds them.</p>
<p>When there are sub-commands, the base command cannot define arguments, only the
sub-commands can do it. If you have a set of common arguments to all sub-commands, you can
define a function that adds them.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@conan_command</span><span class="p">(</span><span class="n">group</span><span class="o">=</span><span class="s2">&quot;MyGroup&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">mycommand</span><span class="p">(</span><span class="n">conan_api</span><span class="p">,</span> <span class="n">parser</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
Expand Down Expand Up @@ -349,7 +351,11 @@ <h2>Commands parameters<a class="headerlink" href="#commands-parameters" title="
<section id="read-more">
<h2>Read more<a class="headerlink" href="#read-more" title="Link to this heading"></a></h2>
<ul class="simple">
<li><p><a class="reference internal" href="../../examples/extensions/commands/clean/custom_command_clean_revisions.html#examples-extensions-commands-clean-revisions"><span class="std std-ref">Custom command to remove recipe and package revisions but the latest package one from the latest recipe one</span></a>.</p></li>
<li><p><a class="reference internal" href="../../examples/extensions/commands/clean/custom_command_clean_revisions.html#examples-extensions-commands-clean-revisions"><span class="std std-ref">Custom command to remove recipe and package revisions but the latest package one
from the latest recipe one</span></a>.</p></li>
<li><p>You can check more examples of Conan custom command in the <em>conan-extensions</em> repository.
There you can find examples of custom commands without sub-commands <a class="reference external" href="https://github.com/conan-io/conan-extensions/blob/main/extensions/commands/art/cmd_server.py">like this one</a>.
and custom commands with sub-commands <a class="reference external" href="https://github.com/conan-io/conan-extensions/blob/main/extensions/commands/cci/cmd_export_all_versions.py">like this one</a>.</p></li>
</ul>
</section>
</section>
Expand Down
2 changes: 1 addition & 1 deletion 2.1/searchindex.js

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions 2/_sources/reference/extensions/custom_commands.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,14 @@ Commands can define their own arguments with the ``argparse`` Python library.
Command help
"""
parser.add_argument("path", nargs="?", help='help for command')
add_reference_args(parser)
...
args = parser.parse_args(*args)
# Use args.path
When there are sub-commands, the base command cannot define arguments, only the sub-commands can do it. If you have a set of common arguments to all sub-commands, you can define a function that adds them.
When there are sub-commands, the base command cannot define arguments, only the
sub-commands can do it. If you have a set of common arguments to all sub-commands, you can
define a function that adds them.

.. code-block:: python
Expand Down Expand Up @@ -243,8 +245,13 @@ These are the passed arguments to any custom command and its sub-commands functi
Normally, they'll be parsed as ``args = parser.parse_args(*args)``. For instance, running :command:`conan mycommand arg1 arg2 arg3`,
the command function will receive them as a Python list-like ``["arg1", "arg2", "arg3"]``.


Read more
---------

- :ref:`Custom command to remove recipe and package revisions but the latest package one from the latest recipe one<examples_extensions_commands_clean_revisions>`.
- :ref:`Custom command to remove recipe and package revisions but the latest package one
from the latest recipe one<examples_extensions_commands_clean_revisions>`.
- You can check more examples of Conan custom command in the *conan-extensions* repository.
There you can find examples of custom commands without sub-commands `like this one
<https://github.com/conan-io/conan-extensions/blob/main/extensions/commands/art/cmd_server.py>`__.
and custom commands with sub-commands `like this one
<https://github.com/conan-io/conan-extensions/blob/main/extensions/commands/cci/cmd_export_all_versions.py>`__.
Binary file modified 2/conan.pdf
Binary file not shown.
12 changes: 9 additions & 3 deletions 2/reference/extensions/custom_commands.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,14 @@ <h2>Argument definition and parsing<a class="headerlink" href="#argument-definit
<span class="sd"> Command help</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;path&quot;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s2">&quot;?&quot;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;help for command&#39;</span><span class="p">)</span>
<span class="n">add_reference_args</span><span class="p">(</span><span class="n">parser</span><span class="p">)</span>
<span class="o">...</span>
<span class="n">args</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
<span class="c1"># Use args.path</span>
</pre></div>
</div>
<p>When there are sub-commands, the base command cannot define arguments, only the sub-commands can do it. If you have a set of common arguments to all sub-commands, you can define a function that adds them.</p>
<p>When there are sub-commands, the base command cannot define arguments, only the
sub-commands can do it. If you have a set of common arguments to all sub-commands, you can
define a function that adds them.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@conan_command</span><span class="p">(</span><span class="n">group</span><span class="o">=</span><span class="s2">&quot;MyGroup&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">mycommand</span><span class="p">(</span><span class="n">conan_api</span><span class="p">,</span> <span class="n">parser</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
Expand Down Expand Up @@ -349,7 +351,11 @@ <h2>Commands parameters<a class="headerlink" href="#commands-parameters" title="
<section id="read-more">
<h2>Read more<a class="headerlink" href="#read-more" title="Link to this heading"></a></h2>
<ul class="simple">
<li><p><a class="reference internal" href="../../examples/extensions/commands/clean/custom_command_clean_revisions.html#examples-extensions-commands-clean-revisions"><span class="std std-ref">Custom command to remove recipe and package revisions but the latest package one from the latest recipe one</span></a>.</p></li>
<li><p><a class="reference internal" href="../../examples/extensions/commands/clean/custom_command_clean_revisions.html#examples-extensions-commands-clean-revisions"><span class="std std-ref">Custom command to remove recipe and package revisions but the latest package one
from the latest recipe one</span></a>.</p></li>
<li><p>You can check more examples of Conan custom command in the <em>conan-extensions</em> repository.
There you can find examples of custom commands without sub-commands <a class="reference external" href="https://github.com/conan-io/conan-extensions/blob/main/extensions/commands/art/cmd_server.py">like this one</a>.
and custom commands with sub-commands <a class="reference external" href="https://github.com/conan-io/conan-extensions/blob/main/extensions/commands/cci/cmd_export_all_versions.py">like this one</a>.</p></li>
</ul>
</section>
</section>
Expand Down
2 changes: 1 addition & 1 deletion 2/searchindex.js

Large diffs are not rendered by default.

0 comments on commit 9d2a72e

Please sign in to comment.