|
6 | 6 | // SPDX-License-Identifier: MIT
|
7 | 7 | //
|
8 | 8 |
|
9 |
| -extern crate clap; |
10 |
| -extern crate gettextrs; |
11 |
| -extern crate plib; |
12 |
| - |
13 | 9 | use clap::{error::ErrorKind, Parser};
|
14 | 10 | use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory};
|
15 | 11 | use plib::PROJECT_NAME;
|
@@ -432,35 +428,6 @@ fn talk(args: Args) -> Result<(), TalkError> {
|
432 | 428 | Ok(())
|
433 | 429 | }
|
434 | 430 |
|
435 |
| -fn main() -> Result<(), Box<dyn std::error::Error>> { |
436 |
| - let args = Args::try_parse().unwrap_or_else(|err| { |
437 |
| - if err.kind() == ErrorKind::DisplayHelp || err.kind() == ErrorKind::DisplayVersion { |
438 |
| - // Print help or version message |
439 |
| - eprintln!("{}", err); |
440 |
| - } else { |
441 |
| - // Print custom error message |
442 |
| - eprintln!("Error parsing arguments: {}", err); |
443 |
| - } |
444 |
| - |
445 |
| - // Exit with a non-zero status code |
446 |
| - std::process::exit(1); |
447 |
| - }); |
448 |
| - setlocale(LocaleCategory::LcAll, ""); |
449 |
| - textdomain(PROJECT_NAME)?; |
450 |
| - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; |
451 |
| - |
452 |
| - let mut exit_code = 0; |
453 |
| - |
454 |
| - register_signals(); |
455 |
| - |
456 |
| - if let Err(err) = talk(args) { |
457 |
| - exit_code = 1; |
458 |
| - eprint!("{}", err); |
459 |
| - } |
460 |
| - |
461 |
| - process::exit(exit_code) |
462 |
| -} |
463 |
| - |
464 | 431 | /// Checks if the standard input is a TTY (terminal).
|
465 | 432 | ///
|
466 | 433 | /// # Returns
|
@@ -1742,3 +1709,32 @@ fn get_terminal_size() -> (u16, u16) {
|
1742 | 1709 |
|
1743 | 1710 | (size.ws_col, size.ws_row)
|
1744 | 1711 | }
|
| 1712 | + |
| 1713 | +fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 1714 | + let args = Args::try_parse().unwrap_or_else(|err| { |
| 1715 | + if err.kind() == ErrorKind::DisplayHelp || err.kind() == ErrorKind::DisplayVersion { |
| 1716 | + // Print help or version message |
| 1717 | + eprintln!("{}", err); |
| 1718 | + } else { |
| 1719 | + // Print custom error message |
| 1720 | + eprintln!("Error parsing arguments: {}", err); |
| 1721 | + } |
| 1722 | + |
| 1723 | + // Exit with a non-zero status code |
| 1724 | + std::process::exit(1); |
| 1725 | + }); |
| 1726 | + setlocale(LocaleCategory::LcAll, ""); |
| 1727 | + textdomain(PROJECT_NAME)?; |
| 1728 | + bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; |
| 1729 | + |
| 1730 | + let mut exit_code = 0; |
| 1731 | + |
| 1732 | + register_signals(); |
| 1733 | + |
| 1734 | + if let Err(err) = talk(args) { |
| 1735 | + exit_code = 1; |
| 1736 | + eprint!("{}", err); |
| 1737 | + } |
| 1738 | + |
| 1739 | + process::exit(exit_code) |
| 1740 | +} |
0 commit comments