[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"article-rust-cli-project-5-practical-steps-en":3,"article-related-rust-cli-project-5-practical-steps-en":31,"series-tools-736107e8-43ea-4213-b251-b1bbce64a7f2":84},{"id":4,"slug":5,"title":6,"content":7,"summary":8,"source":9,"source_url":10,"author":11,"image_url":12,"cover_image":12,"category":13,"language":14,"translated_content":11,"related_article_id":15,"keywords":16,"key_takeaways":23,"views":27,"created_at":28,"published_at":29,"topic_cluster_id":30},"736107e8-43ea-4213-b251-b1bbce64a7f2","rust-cli-project-5-practical-steps-en","Rust CLI Project in 5 Practical Steps","\u003Cp data-speakable=\"summary\">Build a \u003Ca href=\"\u002Ftag\u002Frust\">Rust\u003C\u002Fa> CLI weather tool with Cargo, Tokio, Reqwest, and Clap.\u003C\u002Fp>\u003Cp>This guide is for developers who already know another language and want a fast path to a working Rust command-line app.\u003C\u002Fp>\u003Cp>By the end, you will have a compiled CLI project, a weather lookup command, basic async HTTP calls, and a testable codebase you can extend.\u003C\u002Fp>\u003Ch2>Before you start\u003C\u002Fh2>\u003Cul>\u003Cli>Rust toolchain 1.95.0 stable installed with \u003Ca href=\"https:\u002F\u002Frustup.rs\u002F\">rustup\u003C\u002Fa>\u003C\u002Fli>\u003Cli>Cargo 1.95.0, rust-analyzer 2026-04-14 release, clippy, and rustfmt\u003C\u002Fli>\u003Cli>Node not required; a Unix-like shell on macOS, Linux, or WSL2 on Windows\u003C\u002Fli>\u003Cli>VS Code or Neovim with rust-analyzer support\u003C\u002Fli>\u003Cli>A free API key for the weather service you plan to use, if your endpoint requires one\u003C\u002Fli>\u003Cli>Tokio 1.40.0, reqwest 0.12.7, serde 1.0.210, serde_json 1.0.128, clap 4.5.17, anyhow 1.0.82\u003C\u002Fli>\u003C\u002Ful>\u003Ch2>Step 1: Install the Rust toolchain\u003C\u002Fh2>\u003Cp>Goal: get a clean, up-to-date Rust install that matches the tutorial versions.\u003C\u002Fp>\n\u003Cfigure class=\"my-6\">\u003Cimg src=\"https:\u002F\u002Fxxdpdyhzhpamafnrdkyq.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fcovers\u002Finline-1780898582667-xfn1.png\" alt=\"Rust CLI Project in 5 Practical Steps\" class=\"rounded-xl w-full\" loading=\"lazy\" \u002F>\u003C\u002Ffigure>\n\u003Cpre>\u003Ccode>curl --proto '=https' --tlsv1.2 -sSf https:\u002F\u002Fsh.rustup.rs | sh\nsource \"$HOME\u002F.cargo\u002Fenv\"\nrustc --version\ncargo --version\nrustup component add rust-analyzer clippy rustfmt\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>Verification: you should see rustc 1.95.0 and cargo 1.95.0, which confirms the stable toolchain is ready.\u003C\u002Fp>\u003Ch2>Step 2: Create the Cargo project\u003C\u002Fh2>\u003Cp>Goal: generate a binary crate with the standard Rust layout and build metadata.\u003C\u002Fp>\n\u003Cfigure class=\"my-6\">\u003Cimg src=\"https:\u002F\u002Fxxdpdyhzhpamafnrdkyq.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fcovers\u002Finline-1780898579259-jslx.png\" alt=\"Rust CLI Project in 5 Practical Steps\" class=\"rounded-xl w-full\" loading=\"lazy\" \u002F>\u003C\u002Ffigure>\n\u003Cpre>\u003Ccode>cargo new weather_cli\ncd weather_cli\ncargo run\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>Verification: you should see Hello, world! and a target\u002Fdebug\u002Fweather_cli binary, which means Cargo can compile and run your app.\u003C\u002Fp>\u003Ch2>Step 3: Add CLI arguments and config\u003C\u002Fh2>\u003Cp>Goal: define a real command interface so users can pass a city name, units, and output options.\u003C\u002Fp>\u003Cpre>\u003Ccode>cargo add clap --features derive\ncargo add anyhow\n\nuse clap::Parser;\n\n#[derive(Parser, Debug)]\nstruct Args {\n    #[arg(short, long)]\n    city: String,\n}\n\nfn main() {\n    let args = Args::parse();\n    println!(\"City: {}\", args.city);\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>Verification: you should see a parsed city value when you run cargo run -- --city Tokyo, which proves Clap is wired correctly.\u003C\u002Fp>\u003Ch2>Step 4: Fetch weather data asynchronously\u003C\u002Fh2>\u003Cp>Goal: turn the CLI into a real networked tool using Tokio, Reqwest, and Serde.\u003C\u002Fp>\u003Cpre>\u003Ccode>cargo add tokio --features full\ncargo add reqwest --features json,rustls-tls\ncargo add serde --features derive\ncargo add serde_json\n\n#[tokio::main]\nasync fn main() -> anyhow::Result\u003C()> {\n    let body = reqwest::get(\"https:\u002F\u002Fexample.com\u002Fweather.json\").await?.text().await?;\n    println!(\"{}\", body);\n    Ok(())\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>Verification: you should see an HTTP response body or a parsed JSON payload, which confirms async execution and networking both work.\u003C\u002Fp>\u003Ch2>Step 5: Test, format, and ship the binary\u003C\u002Fh2>\u003Cp>Goal: make the project reproducible, linted, and ready for distribution.\u003C\u002Fp>\u003Cpre>\u003Ccode>cargo fmt\ncargo clippy\ncargo test\ncargo build --release\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>Verification: you should see clean formatting, no clippy errors, passing tests, and a release binary in target\u002Frelease\u002Fweather_cli.\u003C\u002Fp>\u003Ctable>\u003Cthead>\u003Ctr>\u003Cth>Metric\u003C\u002Fth>\u003Cth>Before\u002FBaseline\u003C\u002Fth>\u003Cth>After\u002FResult\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\u003Ctbody>\u003Ctr>\u003Ctd>Project state\u003C\u002Ftd>\u003Ctd>No Rust app\u003C\u002Ftd>\u003Ctd>Working CLI binary\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Runtime model\u003C\u002Ftd>\u003Ctd>Synchronous placeholder\u003C\u002Ftd>\u003Ctd>Tokio async runtime\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Dependency coverage\u003C\u002Ftd>\u003Ctd>None\u003C\u002Ftd>\u003Ctd>Clap, Reqwest, Serde, Tokio\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Build output\u003C\u002Ftd>\u003Ctd>Debug-only\u003C\u002Ftd>\u003Ctd>Optimized release binary\u003C\u002Ftd>\u003C\u002Ftr>\u003C\u002Ftbody>\u003C\u002Ftable>\u003Ch2>Common mistakes\u003C\u002Fh2>\u003Cul>\u003Cli>Using a system package manager instead of rustup. Fix: uninstall the old toolchain or move ~\u002F.cargo\u002Fbin ahead of system paths.\u003C\u002Fli>\u003Cli>Forgetting the -- separator before CLI flags. Fix: run cargo run -- --city Tokyo so Cargo does not eat your app arguments.\u003C\u002Fli>\u003Cli>Mixing sync and async code without Tokio. Fix: keep network calls inside an async main annotated with #[tokio::main].\u003C\u002Fli>\u003C\u002Ful>\u003Ch2>What's next\u003C\u002Fh2>\u003Cp>From here, add real \u003Ca href=\"\u002Ftag\u002Fapi\">API\u003C\u002Fa> parsing, error types with thiserror, integration tests, and a crates.io release workflow so the CLI can evolve into a polished tool.\u003C\u002Fp>","Build a Rust CLI weather tool with Cargo, Tokio, Reqwest, and Clap.","tech-insider.org","https:\u002F\u002Ftech-insider.org\u002Frust-programming-tutorial-cli-project-2026\u002F",null,"https:\u002F\u002Fxxdpdyhzhpamafnrdkyq.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fcovers\u002Finline-1780898582667-xfn1.png","tools","en","871c382b-188c-4eb7-a2b6-978e0183f18f",[17,18,19,20,21,22],"Rust","Cargo","Tokio","Reqwest","Clap","Serde",[24,25,26],"Rust CLI apps are easiest to start with rustup, Cargo, and a binary crate.","Clap handles arguments, Tokio handles async execution, and Reqwest plus Serde handle HTTP and JSON.","Formatting, linting, tests, and release builds turn a tutorial project into something shippable.",0,"2026-06-08T06:02:31.670073+00:00","2026-06-08T06:02:31.661+00:00","792f1e10-dc48-4f25-ac6d-741ba38ea9f8",{"tags":32,"relatedLang":43,"relatedPosts":47},[33,35,37,39,41],{"name":17,"slug":34},"rust",{"name":20,"slug":36},"reqwest",{"name":21,"slug":38},"clap",{"name":19,"slug":40},"tokio",{"name":18,"slug":42},"cargo",{"id":15,"slug":44,"title":45,"language":46},"rust-cli-project-5-practical-steps-zh","Rust CLI 天氣工具五步實作","zh",[48,54,60,66,72,78],{"id":49,"slug":50,"title":51,"cover_image":52,"image_url":52,"created_at":53,"category":13},"99bfce29-7722-4619-9537-0c94c15ad5fc","cursor-teams-pricing-adds-96-premium-seat-en","Cursor Teams pricing adds $96 Premium seat","https:\u002F\u002Fxxdpdyhzhpamafnrdkyq.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fcovers\u002Finline-1780909376960-n787.png","2026-06-08T09:02:25.546066+00:00",{"id":55,"slug":56,"title":57,"cover_image":58,"image_url":58,"created_at":59,"category":13},"a0ebdaf9-3a82-4c5a-9af6-d66ccc860e5e","awesome-ai-summerschool-ai-events-shortlist-en","awesome-ai-summerschool turns AI events into a shortlist","https:\u002F\u002Fxxdpdyhzhpamafnrdkyq.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fcovers\u002Finline-1780905814274-elcy.png","2026-06-08T08:02:47.048945+00:00",{"id":61,"slug":62,"title":63,"cover_image":64,"image_url":64,"created_at":65,"category":13},"071a2cea-17a5-4c4a-87cc-0d20ed20cbbd","rustup-rust-official-toolchain-installer-en","Rustup is Rust’s official toolchain installer","https:\u002F\u002Fxxdpdyhzhpamafnrdkyq.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fcovers\u002Finline-1780903081166-cox8.png","2026-06-08T07:17:37.744868+00:00",{"id":67,"slug":68,"title":69,"cover_image":70,"image_url":70,"created_at":71,"category":13},"b9d06f56-85d2-4db8-8e4c-f940da4e95ec","launch-site-rust-loot-routes-en","Launch Site turns Rust loot runs into routes","https:\u002F\u002Fxxdpdyhzhpamafnrdkyq.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fcovers\u002Finline-1780897699339-0shr.png","2026-06-08T05:47:50.323264+00:00",{"id":73,"slug":74,"title":75,"cover_image":76,"image_url":76,"created_at":77,"category":13},"267be20a-b87f-45fd-a6ec-79d136955b91","open-source-rag-stack-build-plan-en","Open Source RAG Stack Turns Chaos Into a Build Plan","https:\u002F\u002Fxxdpdyhzhpamafnrdkyq.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fcovers\u002Finline-1780872537488-owb6.png","2026-06-07T22:47:55.794337+00:00",{"id":79,"slug":80,"title":81,"cover_image":82,"image_url":82,"created_at":83,"category":13},"fb2600b9-89a3-493e-9d04-cd7823ac10cc","github-rag-production-list-battle-tested-tools-en","49 stars for GitHub’s RAG production list","https:\u002F\u002Fxxdpdyhzhpamafnrdkyq.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fcovers\u002Finline-1780870666109-xv1v.png","2026-06-07T22:17:20.678948+00:00",[85,90,95,100,105,110,115,120,125,130],{"id":86,"slug":87,"title":88,"created_at":89},"8008f1a9-7a00-4bad-88c9-3eedc9c6b4b1","surepath-ai-mcp-policy-controls-en","SurePath AI's New MCP Policy Controls Enhance AI Security","2026-03-26T01:26:52.222015+00:00",{"id":91,"slug":92,"title":93,"created_at":94},"27e39a8f-b65d-4f7b-a875-859e2b210156","mcp-standard-ai-tools-2026-en","MCP Standard in 2026: Integrating AI Tools","2026-03-26T01:27:43.127519+00:00",{"id":96,"slug":97,"title":98,"created_at":99},"165f9a19-c92d-46ba-b3f0-7125f662921d","rag-2026-transforming-enterprise-ai-en","How RAG in 2026 is Transforming Enterprise AI","2026-03-26T01:28:11.485236+00:00",{"id":101,"slug":102,"title":103,"created_at":104},"6a2a8e6e-b956-49d8-be12-cc47bdc132b2","mastering-ai-prompts-2026-guide-en","Mastering AI Prompts: A 2026 Guide for Developers","2026-03-26T01:29:07.835148+00:00",{"id":106,"slug":107,"title":108,"created_at":109},"3ab2c67e-4664-4c67-a013-687a2f605814","garry-tan-open-sources-claude-code-toolkit-en","Garry Tan Open-Sources a Claude Code Toolkit","2026-03-26T08:26:20.245934+00:00",{"id":111,"slug":112,"title":113,"created_at":114},"66a7cbf8-7e76-41d4-9bbf-eaca9761bf69","github-ai-projects-to-watch-in-2026-en","20 GitHub AI Projects to Watch in 2026","2026-03-26T08:28:09.752027+00:00",{"id":116,"slug":117,"title":118,"created_at":119},"9f332fda-eace-448a-a292-2283951eee71","practical-github-guide-learning-ml-2026-en","A Practical GitHub Guide to Learning ML in 2026","2026-03-27T01:16:50.125678+00:00",{"id":121,"slug":122,"title":123,"created_at":124},"1b1f637d-0f4d-42bd-974b-07b53829144d","aiml-2026-student-ai-ml-lab-repo-review-en","AIML-2026 Is a Bare-Bones Student Lab Repo","2026-03-27T01:21:51.661231+00:00",{"id":126,"slug":127,"title":128,"created_at":129},"6d1bf3f6-e191-4d30-b55b-8a0722fa6afe","ai-trending-github-repos-and-research-feeds-en","AI Trending Tracks Repos and Research Feeds","2026-03-27T01:31:35.709532+00:00",{"id":131,"slug":132,"title":133,"created_at":134},"010539a1-4c3a-4bd3-937a-26616422ee0d","awesome-ai-for-science-research-tools-map-en","Awesome AI for Science Is Becoming a Real Research Map","2026-03-27T01:46:50.89513+00:00"]