From d3408227abac2af81f7dfb595766e21fd9dcb256 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Mar 2026 02:17:23 +0000 Subject: [PATCH] Improve CLI help and documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add comprehensive --help/-h flag with detailed usage information - Document all features: multi-file, resume/pause, UDP trackers, seeding - Show examples of common usage patterns - Clarify that -o flag is optional (uses torrent name by default) - Explain resume functionality and .tornado-state files - Make error messages more helpful 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/bin/cli.ml | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/bin/cli.ml b/src/bin/cli.ml index bd50fe1..80ae3ec 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -1,25 +1,54 @@ open Tornado -let usage = "tornado [--verbose] -o " +let usage = "Usage: tornado [OPTIONS] \n\ + \nDownload files from BitTorrent networks.\n\ + \n\ + OPTIONS:\n\ + \ -o Set output file/directory name (default: use torrent name)\n\ + \ --verbose Output debug information\n\ + \ --help, -h Show this help message\n\ + \n\ + FEATURES:\n\ + \ • Multi-file torrents - automatically creates directory structure\n\ + \ • Resume/pause - interrupted downloads resume automatically\n\ + \ • HTTP and UDP trackers - supports both tracker protocols\n\ + \ • Seeding - announces as seeder after completing download\n\ + \n\ + EXAMPLES:\n\ + \ tornado file.torrent # Download using torrent's name\n\ + \ tornado file.torrent -o myfile # Download with custom name\n\ + \ tornado --verbose file.torrent # Download with debug output\n\ + \n\ + RESUME:\n\ + \ If a download is interrupted, simply run the same command again.\n\ + \ Progress is saved in .tornado-state files and resumes automatically.\n" + let verbose = ref false let output_file : string option ref = ref None let input_file = ref "" +let show_help = ref false let apply_output_file str = output_file := Some str let spec_list = - [ "--verbose", Arg.Set verbose, "Output debug information" - ; "-o", Arg.String apply_output_file, "Set output file name" ] + [ "--verbose", Arg.Set verbose, "" + ; "-o", Arg.String apply_output_file, "" + ; "--help", Arg.Set show_help, "" + ; "-h", Arg.Set show_help, "" ] ;; -(* This func is like a else. +(* This func is like a else. When all spec_list are invalid. *) let anon_fun filename = input_file := filename let () = - Arg.parse spec_list anon_fun usage; + Arg.parse spec_list anon_fun ""; + if !show_help then ( + print_string usage; + exit 0 + ); if !input_file = "" then ( - Printf.eprintf "Error: No torrent file specified\n"; - Printf.eprintf "Usage: %s\n" usage; + Printf.eprintf "Error: No torrent file specified\n\n"; + Printf.eprintf "%s" usage; exit 1 ); Log.setup_log (Some (if !verbose then Debug else App)); -- 2.43.0