1#![warn(unsafe_code)]
2pub mod argument;
70pub mod command;
71pub mod complete;
72pub mod completion;
73pub mod context;
74pub mod decorators;
75pub mod error;
76pub mod formatting;
77pub mod group;
78pub mod option;
79pub mod parameter;
80pub mod parser;
81mod source;
82pub mod termui;
83pub mod testing;
84pub mod types;
85pub mod utils;
86
87pub use argument::{AnyTypeConverter, Argument, ArgumentBuilder, ShellCompleteCallback};
88pub use command::{Command, CommandBuilder, CommandCallback};
89pub use context::{get_current_context, pop_context, push_context, Context, ContextBuilder};
90pub use decorators::{make_pass_decorator, PassDecorator};
91pub use error::{ClickError, ErrorContext, ParamType, Result};
92pub use group::{
93 CommandCollection, CommandCollectionBuilder, CommandLike, Group, GroupBuilder, ResultCallback,
94};
95pub use option::{parse_option_name, split_option_names, ClickOption, OptionBuilder};
96pub use parameter::{DeprecationInfo, Nargs, Parameter, ParameterConfig};
97pub use parser::{split_opt, OptionAction, OptionParser, ParseResult, ParsedValue};
98pub use source::ParameterSource;
99
100pub fn try_run<I>(cmd: &dyn CommandLike, args: I) -> Result<()>
102where
103 I: IntoIterator<Item = String>,
104{
105 cmd.main(args.into_iter().collect())
106}
107
108pub fn run(cmd: &dyn CommandLike) {
112 if let Err(e) = try_run(cmd, std::env::args().skip(1)) {
113 eprintln!("{}", e.format_full());
114 std::process::exit(e.exit_code());
115 }
116}
117
118pub fn run_with_completion(cmd: &dyn CommandLike, prog_name: &str, complete_var: &str) {
123 let completion_opt = completion::make_completion_option(complete_var);
124 if completion_opt.handle_completion(cmd, prog_name) {
125 return;
126 }
127 run(cmd);
128}
129
130pub use formatting::{
132 detect_terminal_width, get_terminal_width, make_rule, split_into_lines, truncate_text,
133 wrap_text, HelpFormatter,
134};
135
136#[cfg(feature = "derive")]
138pub use click_derive::{command, group, Command, Group};
139
140pub use types::{
142 BoolType,
144 Choice,
145 CompletionItem,
147 DateTimeType,
148 FileMode,
149 FileType,
150 FloatRange,
151 FloatType,
152 IntRange,
153 IntType,
154 LazyFile,
155 PathType,
156 StringType,
157 TupleType,
158 TupleValue,
159 TypeConverter,
161 UnprocessedType,
162 UuidType,
163 BOOL,
165 FLOAT,
166 INT,
167 STRING,
168 UNPROCESSED,
169 UUID,
170};
171
172pub use termui::{
174 clear, confirm, echo, echo_via_pager, edit_text, get_terminal_size, getchar, isatty, launch,
175 pause, progressbar, prompt, secho, stderr_isatty, stdin_isatty, stdout_isatty,
176 strip_ansi_codes, style, Color, ProgressBar,
177};
178
179pub use completion::{shell_complete, BashComplete, FishComplete, ShellComplete, ZshComplete};
181
182pub use testing::{CliRunner, InvokeResult, IsolatedFilesystem};
184
185pub use utils::{
187 expand_path, format_filename, get_app_dir, get_binary_stdout, get_os_args, get_text_stderr,
188 get_text_stdout, safecall, should_strip_ansi,
189};