{"id":1915,"date":"2015-02-19T01:21:16","date_gmt":"2015-02-18T16:21:16","guid":{"rendered":"http:\/\/daily.belltail.jp\/?p=1915"},"modified":"2015-02-19T01:23:26","modified_gmt":"2015-02-18T16:23:26","slug":"argparse%e3%81%8b%e3%82%89zsh%e8%a3%9c%e5%ae%8c%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88%e3%82%92%e5%90%90%e3%81%84%e3%81%a6%e3%81%8f%e3%82%8c%e3%82%8bgenzshcomp%e3%81%a7qol%e3%81%8c%e4%b8%8a","status":"publish","type":"post","link":"https:\/\/daily.belltail.jp\/?p=1915","title":{"rendered":"Python\u306eargparse\u304b\u3089zsh\u88dc\u5b8c\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5410\u3044\u3066\u304f\u308c\u308bgenzshcomp\u3067QoL\u304c\u4e0a\u304c\u3063\u305f"},"content":{"rendered":"<p>\u30bf\u30c4\u30ce\u30aa\u30c8\u30b7\u30b4\u3063\u3066\u3001\u3042\u306e\u898b\u305f\u76ee\u306a\u306e\u3067\u3059\u304c\u3001\u5b9f\u306f\u9b5a\u985e\u3060\u3063\u305f\u3093\u3067\u3059\u3002\u306a\u3093\u3068\u306a\u304f\u7532\u6bbb\u985e\u3068\u601d\u3063\u3066\u3044\u305f\u3002\u6700\u5927\u306e\u7a2e\u306f30cm\u3092\u8d85\u3048\u308b\u305d\u3046\u3067\u3001\u3042\u306e\u59ff\u3067\u305d\u306e\u5927\u304d\u3055\u3068\u3044\u3046\u306e\u3092\u60f3\u50cf\u3059\u308b\u3068\u3061\u3087\u3063\u3068\u3053\u308f\u3044\u3002\u3002<\/p>\n<p>Python\u3067\u306f\u3001\u304b\u306a\u308a\u5f37\u529b\u306a\u30b3\u30de\u30f3\u30c9\u5f15\u6570\u30d1\u30fc\u30b5\u3068\u3057\u3066[http:\/\/docs.python.jp\/3.4\/library\/argparse.html:title=argparse]\u304c\u4f7f\u3048\u307e\u3059\u3002<br \/>\n\u3044\u308d\u3093\u306a\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3082\u3064\u30b3\u30de\u30f3\u30c9\u3092\u4f5c\u3063\u305f\u3089\u3001\u5f15\u6570\u306e\u5165\u529b\u3082\u9762\u5012\u3002<br \/>\n\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u81ea\u5206\u306e\u4f5c\u3063\u305fPython\u30b9\u30af\u30ea\u30d7\u30c8\u5c02\u7528\u306e\u88dc\u5b8c\u304czsh\u3067\u52b9\u304f\u3088\u3046\u306b\u3057\u305f\u3044\u306a\u30fc\u3068\u601d\u3063\u3066\u3044\u305f\u3089\u3001[https:\/\/pypi.python.org\/pypi\/genzshcomp\/0.5.2:title=genzshcomp]\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u30b3\u30fc\u30c9\u306e\u307b\u3046\u306b\u306f\u5168\u304f\u624b\u3092\u5165\u308c\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u666e\u901a\u306bargparse\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8a18\u8ff0\u3057\u3066\u3044\u3063\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306f\u7279\u306b\u610f\u5473\u306f\u306a\u3044\u3067\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#!\/usr\/bin\/env python\r\n# -*- coding: utf-8 -*-\r\nimport argparse\r\n\r\nparser = argparse.ArgumentParser(description = &quot;Description of your code&quot;)\r\nparser.add_argument('--input-file', '-i', type = str, required = True, help = 'Filename of input data')\r\nparser.add_argument('--nprocess', '-n', type = int, help = 'Number of iteration')\r\nparser.add_argument('--algorithm', '-a', choices=&#x5B;'minmax', 'alphabeta'], help = 'Algorithm')\r\nparser.add_argument('--output', '-o', type = str, help = 'Filename of output')\r\nargs = parser.parse_args()\r\n<\/pre>\n<p>\u3053\u3053\u3067\u3001\u88dc\u5b8c\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7f6e\u304f\u305f\u3081\u306e\u5834\u6240\u3068\u8a2d\u5b9a\u3092\u78ba\u4fdd\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n% mkdir -p $HOME\/.zsh\/completion\r\n% echo &quot;fpath=($HOME\/.zsh\/completion\/ $fpath)&quot; &gt;&gt; ~\/.zshrc\r\n% echo &quot;autoload -Uz compinit&quot; &gt;&gt; ~\/.zshrc\r\n% echo compinit &gt;&gt; ~\/.zshrc\r\n<\/pre>\n<p>\u66f8\u3044\u305fPython\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5bfe\u3057\u3066\u3001argparse\u306e\u30d8\u30eb\u30d7\u51fa\u529b\u3092genzshcomp\u306b\u304b\u307e\u305b\u308b\u3068\u88dc\u5b8c\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u307e\u3059\u3002\u306a\u306b\u305d\u308c\u3059\u3054\u3044\uff57\uff57<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n% .\/prog.py --help | genzshcomp &gt; ~\/.zsh\/completion\/_prog\r\n% source ~\/.zshrc\r\n<\/pre>\n<p>\u3053\u308c\u3067\u3001zshrc\u3092\u518d\u8aad\u307f\u8fbc\u307f\u3059\u308c\u3070\u88dc\u5b8c\u304c\u52b9\u304f\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u306a\u304a<u>\u88dc\u5b8c\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u3001\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u3067\u59cb\u307e\u308b\u30d5\u30a1\u30a4\u30eb\u540d<\/u>\u3067\u306a\u3051\u308c\u3070\u3044\u3051\u307e\u305b\u3093\u3002\u30cf\u30de\u3063\u305f\u305c\u3002\u3002\u3002<\/p>\n<p><a href=\"http:\/\/daily.belltail.jp\/wp-content\/uploads\/2015\/02\/completion_scr.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/daily.belltail.jp\/wp-content\/uploads\/2015\/02\/completion_scr.gif\" alt=\"completion_scr\" width=\"584\" height=\"344\" class=\"aligncenter size-full wp-image-1918\" \/><\/a><\/p>\n<p>\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u65b9\u3092\u66f8\u304d\u63db\u3048\u305f\u3089\u3001completion\u30d5\u30a1\u30a4\u30eb\u3082\u4f75\u305b\u3066\u66f4\u65b0\u3057\u3066zsh\u3092\u30ea\u30ed\u30fc\u30c9\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>genzshcomp\u306b\u6e21\u305b\u308b\u60c5\u5831\u306b\u306f\u9650\u308a\u304c\u3042\u308b\u305f\u3081\u3001\u4f8b\u3048\u3070\u5b9f\u5728\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3067\u306a\u3044\u3068\u30c0\u30e1\u3068\u304b\u3001\u4f55\u3089\u304b\u306e\u30b3\u30de\u30f3\u30c9\u306e\u7d50\u679c\u3092\u88dc\u5b8c\u7d50\u679c\u306b\u51fa\u3059\uff08\u4f8b\u3048\u3070git\u306e\u30d6\u30e9\u30f3\u30c1\u540d\u88dc\u5b8c\uff09\u307f\u305f\u3044\u306a\u3053\u3068\u306f\u96e3\u3057\u305d\u3046\u3067\u3059\u3002<br \/>\n\u305d\u308c\u3067\u3082\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u4f55\u6307\u5b9a\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u304b\u3063\u305f\u3063\u3051\uff1f\u3068\u601d\u3063\u305f\u6642\u3071\u3063\u3068\u898b\u3089\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3053\u3068\u3067\u3001\u3068\u3066\u3082QoL\u304c\u4e0a\u304c\u3063\u305f\u306e\u3067\u3001\u30aa\u30b9\u30b9\u30e1\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30bf\u30c4\u30ce\u30aa\u30c8\u30b7\u30b4\u3063\u3066\u3001\u3042\u306e\u898b\u305f\u76ee\u306a\u306e\u3067\u3059\u304c\u3001\u5b9f\u306f\u9b5a\u985e\u3060\u3063\u305f\u3093\u3067\u3059\u3002\u306a\u3093\u3068\u306a\u304f\u7532\u6bbb\u985e\u3068\u601d\u3063\u3066\u3044\u305f\u3002\u6700\u5927\u306e\u7a2e\u306f30cm\u3092\u8d85\u3048\u308b\u305d\u3046\u3067\u3001\u3042\u306e\u59ff\u3067\u305d\u306e\u5927\u304d\u3055\u3068\u3044\u3046\u306e\u3092\u60f3\u50cf\u3059\u308b\u3068\u3061\u3087\u3063\u3068\u3053\u308f\u3044\u3002\u3002 Python\u3067\u306f\u3001\u304b\u306a\u308a\u5f37\u529b\u306a\u30b3\u30de [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[48,38,39],"class_list":["post-1915","post","type-post","status-publish","format-standard","hentry","category-1","tag-python","tag-38","tag-tips"],"_links":{"self":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts\/1915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1915"}],"version-history":[{"count":0,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts\/1915\/revisions"}],"wp:attachment":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}