{"id":11494,"date":"2023-02-28T03:14:36","date_gmt":"2023-02-27T18:14:36","guid":{"rendered":"https:\/\/www.webcyou.com\/?p=11494"},"modified":"2023-02-28T03:14:39","modified_gmt":"2023-02-27T18:14:39","slug":"dart%e3%81%a7%e3%81%95%e3%81%8f%e3%81%a3%e3%81%a8cli%e3%83%84%e3%83%bc%e3%83%ab%e4%bd%9c%e6%88%90%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=11494","title":{"rendered":"Dart\u3067\u3055\u304f\u3063\u3068CLI\u30c4\u30fc\u30eb\u4f5c\u6210\u3002"},"content":{"rendered":"\n<p>\u3069\u3082\u3067\u3059\u3002<\/p>\n<p>\u4eca\u5e74\u306f\u4f55\u304b\u3068Dart\u3092\u6271\u3063\u3066\u884c\u304f\u3060\u308d\u3046\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u307e\u305a\u306f\u30b5\u30af\u30c3\u3068CLI\u30c4\u30fc\u30eb\u306e\u4f5c\u6210\u3092\u884c\u3063\u3066\u884c\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306e\u5185\u5bb9\u306f\u4e3b\u306bDart\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u8a18\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u8a73\u7d30\u306b\u95a2\u3057\u3066\u306f\u305d\u3061\u3089\u3092\u53c2\u7167\u3057\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u00a0<\/p>\n<p><strong>Dart\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/strong><\/p>\n<p><a href=\"https:\/\/dart.dev\/tutorials\/server\/get-started\">https:\/\/dart.dev\/tutorials\/server\/get-started<\/a><\/p>\n<p>\u00a0<\/p>\n<h4>DartPad<\/h4>\n<p>\u65e9\u901f\u3001Dart\u3092\u66f8\u3044\u3066\u884c\u304d\u305f\u3044\u306e\u3067\u3059\u304c\u3001Dart\u3092\u30b5\u30af\u30c3\u3068\u8a66\u3057\u305f\u3044\u5834\u5408\u3001\u30d6\u30e9\u30a6\u30b6\u3067\u5b9f\u884c\u53ef\u80fd\u306aPlayGround\u74b0\u5883\u306e\u300cDartPad\u300d\u3082\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u308f\u3056\u308f\u3056\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4f5c\u6210\u3059\u308b\u5fc5\u8981\u3082\u306a\u3044\u5834\u5408\u306f\u3053\u3061\u3089\u3067\u8a66\u3057\u3066\u3082\u826f\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u00a0<\/p>\n<p><strong>DartPad<\/strong><\/p>\n<p><a href=\"https:\/\/dartpad.dev\/\">https:\/\/dartpad.dev\/<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11496\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2023\/02\/dartpad.jpg\" alt=\"\" width=\"700\" height=\"379\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2023\/02\/dartpad.jpg 700w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2023\/02\/dartpad-300x162.jpg 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<h4>Dart\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h4>\n<p>\u305d\u308c\u3067\u306f\u3001Mac\u74b0\u5883\u306bdart\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>brew\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u53ef\u80fd\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u00a0<\/p>\n<p><strong>Mac<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ brew tap dart-lang\/dart\nbrew install dart<\/pre>\n<p>\u00a0<\/p>\n<p>\u3053\u3061\u3089\u3001Flutter SDK\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u308c\u3070dart\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>Flutter SDK<\/strong><\/p>\n<p><a href=\"https:\/\/docs.flutter.dev\/get-started\/install\">https:\/\/docs.flutter.dev\/get-started\/install<\/a><\/p>\n<p>\u00a0<\/p>\n<p>Dart\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u305f\u304b\u78ba\u8a8d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dart --version<\/pre>\n<p>\u00a0<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">Dart SDK version: 3.0.0-179.0.dev (dev) (Fri Jan 27 21:59:59 2023 -0800) on \"macos_arm64\"<\/pre>\n<p>version: 3.0.0-179.0.dev\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u308b\u3002<\/p>\n<h4>CLI\u30a2\u30d7\u30ea\u3092\u4f5c\u6210<\/h4>\n<p>dart\u30b3\u30de\u30f3\u30c9\u3067\u30a2\u30d7\u30ea\u306e\u96db\u5f62\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>-t\u30aa\u30d7\u30b7\u30e7\u30f3\u300cconsole\u300d\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u306e\u96db\u5f62\u751f\u6210\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dart create -t console cli<\/pre>\n<p>\u751f\u6210\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">.gitignore\nanalysis_options.yaml\nCHANGELOG.md\npubspec.yaml\nREADME.md\nbin\/cli.dart\nlib\/cli.dart\ntest\/cli_test.dart<\/pre>\n<p>\u00a0<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-11497\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2023\/02\/dart2.jpg\" alt=\"\" width=\"178\" height=\"230\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2023\/02\/dart2.jpg 700w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2023\/02\/dart2-233x300.jpg 233w\" sizes=\"auto, (max-width: 178px) 100vw, 178px\" \/><\/p>\n<p>\u305d\u308c\u3067\u306f\u65e9\u901f\u3001\u30a2\u30d7\u30ea\u3092\u5b9f\u884c\u3002cli\u30d5\u30a9\u30eb\u30c0\u306b\u79fb\u52d5\u3057\u3001dart run\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ cd cli\n$ dart run<\/pre>\n<p>\u4ee5\u4e0b\u306e\u69d8\u306b\u8868\u793a\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">dart run\nBuilding package executable...\nBuilt cli:cli.\nHello world: 42!<\/pre>\n<p>\u00a0<\/p>\n<p>\u300cHello world: 42!\u300d\u304c\u30d7\u30ed\u30b0\u30e9\u30e0\u3088\u308a\u51fa\u529b\u3055\u308c\u305f\u5185\u5bb9\u3067\u3059\u306d\u3002<\/p>\n<p>bin\/cli.dart\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u78ba\u8a8d\u3002<\/p>\n<p>\u00a0<\/p>\n<div>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">import 'package:cli\/cli.dart' as cli;\n\nvoid main(List&lt;String&gt; arguments) {\n  print('Hello world: ${cli.calculate()}!');\n}<\/pre>\n\n<p>Hello world\u6587\u5b57\u5217\u3068cli.calculate()\u95a2\u6570\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>calculate()\u95a2\u6570\u306f\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u00a0<\/p>\n<p>lib\/cli.dart<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">int calculate() {\n  return 6 * 7;\n}<\/pre>\n<p>\u00a0<\/p>\n<p>\u3044\u3084\u3041\u3002<\/p>\n<p>\u3059\u3050\u306bCLI\u30c4\u30fc\u30eb\uff08\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\uff09\u306e\u5b9f\u88c5\u306b\u5165\u308c\u308b\u306e\u3067\u8d85\u4fbf\u5229\u3067\u3059\u306d\u3002<\/p>\n<h5>\u30c6\u30b9\u30c8<\/h5>\n<p>\u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3082\u751f\u6210\u3055\u308c\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>test\/cli_test.dart<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">import 'package:cli\/cli.dart';\nimport 'package:test\/test.dart';\n\nvoid main() {\n  test('calculate', () {\n    expect(calculate(), 42);\n  });\n}<\/pre>\n<p>dart test\u30b3\u30de\u30f3\u30c9\u3067\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dart test\nBuilding package executable... (2.7s)\nBuilt test:test.\n00:00 +1: All tests passed!<\/pre>\n<p>\u00a0<\/p>\n<h4>\u672c\u756a\u7528\u30b3\u30f3\u30d1\u30a4\u30eb<\/h4>\n<p>\u672c\u756a\u3067\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3061\u3089\u3082dart\u30b3\u30de\u30f3\u30c9\u3001\u300cdart compile\u300d\u3092\u7528\u3044\u3066\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dart compile exe bin\/cli.dart<\/pre>\n<p>\u00a0<\/p>\n<p>\u5b9f\u884c\u3059\u308b\u3068cli.exe\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>exe\u30aa\u30d7\u30b7\u30e7\u30f3\u3067self-contained\u3068\u306a\u308a\u3001Dart\u30e9\u30f3\u30bf\u30a4\u30e0\u304c\u7121\u3044\u74b0\u5883\u3067\u3082\u5b9f\u884c\u53ef\u80fd\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002\u3057\u304b\u3057\u306a\u304c\u3089\u3001exe\u62e1\u5f35\u5b50\u306fMac\u3067\u5b9f\u884c\u3067\u304d\u306a\u3044\u306e\u3067\u3001Mac\u3067\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306bMac\u306e\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dart compile exe bin\/cli.dart -o bin\/cli<\/pre>\n<p>-o\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3064\u3051\u3001 bin\/cli\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3002<\/p>\n<p>\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u5b9f\u884c\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ .\/bin\/cli\nHello world: 42!<\/pre>\n<p>\u8d85\u7c21\u5358\u306b\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u306e\u4f5c\u6210\u304c\u884c\u3048\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u306e\u4ed6\u306b\u3082\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u65b9\u5f0f\u3068\u3057\u3066AOT(Ahead Of Time)\u3001JIT(Just In Time)\u306a\u3069\u3082\u9078\u629e\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u7a2e\u985e\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<p>\u00a0<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">Available subcommands:\naot-snapshot Compile Dart to an AOT snapshot.\nexe Compile Dart to a self-contained executable.\njit-snapshot Compile Dart to a JIT snapshot.\njs Compile Dart to JavaScript.\nkernel Compile Dart to a kernel snapshot.<\/pre>\n<p>\u00a0<\/p>\n<p>\u3068\u8a00\u3063\u305f\u611f\u3058\u3067\u3001\u3056\u3063\u3068Dart\u3067CLI\u30c4\u30fc\u30eb\u306e\u4f5c\u6210\u884c\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u8af8\u3005\u3001Dart\u3001Flutter\u3092\u6271\u3063\u3066\u884c\u3053\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u3041\u3002<\/p>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002 \u4eca\u5e74\u306f\u4f55\u304b\u3068Dart\u3092\u6271\u3063\u3066\u884c\u304f\u3060\u308d\u3046\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u307e\u305a\u306f\u30b5\u30af\u30c3\u3068CLI\u30c4\u30fc\u30eb\u306e\u4f5c\u6210\u3092\u884c\u3063\u3066\u884c\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u4eca\u56de\u306e\u5185\u5bb9\u306f\u4e3b\u306bDart\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u8a18\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u8a73\u7d30\u306b\u95a2\u3057\u3066\u306f\u305d\u3061\u3089\u3092\u53c2\u7167\u3057 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":11498,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[300],"tags":[78,118],"class_list":["post-11494","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dart","tag-78","tag-118"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/11494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11494"}],"version-history":[{"count":3,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/11494\/revisions"}],"predecessor-version":[{"id":11500,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/11494\/revisions\/11500"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/media\/11498"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}