<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>xkumiyu</author_name>
  <author_url>https://blog.hatena.ne.jp/xkumiyu/</author_url>
  <blog_title>テクめも</blog_title>
  <blog_url>https://tech-memo.hatenablog.jp/</blog_url>
  <categories>
    <anon>Refactoring</anon>
    <anon>CLI</anon>
    <anon>Python</anon>
  </categories>
  <description>PythonのCLIフレームワークの1つにclickがあります。 デコレータを使って簡単にCLIが作成できますが、1ファイルにすべてのコマンドのコードを書いていくと長くなります。 そこで、CommandCollectionを使って複数のコマンドをマージすることで、コマンド別にファイルを分割する方法を紹介します。 まず、コマンド別のファイルを用意します。 # cli1.py import click @click.group() def cli1(): pass @cli1.command() def cmd1(): &quot;&quot;&quot;Command on cli1&quot;&quot;&quot; # cli2.py import …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftech-memo.hatenablog.jp%2Fentry%2Fclick-file-split&quot; title=&quot;Clickでコマンド別にファイル分割する - テクめも&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>https://cdn.user.blog.st-hatena.com/default_entry_og_image/101358585/1543659980958932</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2020-02-03 10:00:00</published>
  <title>Clickでコマンド別にファイル分割する</title>
  <type>rich</type>
  <url>https://tech-memo.hatenablog.jp/entry/click-file-split</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
