1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//! # Uninews CLI - Command-Line News Scraper
//!
//! A command-line utility for scraping news articles and converting them to Markdown format.
//!
//! ## Usage Examples
//!
//! ### Basic Usage (English output)
//! ```bash
//! uninews "https://www.example.com/article"
//! ```
//!
//! ### Translate to Spanish
//! ```bash
//! uninews "https://www.bbc.com/news/article" --language spanish
//! ```
//!
//! ### Output as JSON
//! ```bash
//! uninews "https://www.example.com/article" --json
//! ```
//!
//! ### Combine language and JSON output
//! ```bash
//! uninews "https://www.example.com/article" -l french -j
//! ```
//!
//! ## Features
//!
//! - π Scrape any news article from its URL
//! - π Automatic conversion to clean Markdown format
//! - π Support for 100+ languages via AI translation
//! - π JSON output for programmatic use
//! - π Powered by OpenAI's GPT models
//! - π‘οΈ Graceful error handling with user-friendly messages
//!
//! ## Setup
//!
//! 1. Set your OpenAI API key:
//! ```bash
//! export OPEN_AI_SECRET="sk-..."
//! ```
//!
//! 2. Run:
//! ```bash
//! cargo run -- "https://example.com/article"
//! ```
//!
//! ## Output Examples
//!
//! ### Human-Readable Format (Default)
//! ```text
//! Article Title Here
//!
//! # Main Heading
//!
//! This is the clean, formatted article content in Markdown.
//!
//! ## Subheading
//!
//! More content here...
//! ```
//!
//! ### JSON Format
//! ```json
//! {
//! "title": "Article Title",
//! "content": "# Main Heading\n\nMarkdown content...",
//! "featured_image_url": "https://example.com/image.jpg",
//! "publication_date": "2024-01-15T10:30:00Z",
//! "author": "Jane Doe",
//! "error": ""
//! }
//! ```
use Parser;
use universal_scrape;
/// Command line arguments for the Uninews scraper.
///
/// This struct defines all available CLI options for scraping news articles.
/// It uses the `clap` crate for automatic argument parsing and validation.
/// Main entry point for the Uninews CLI application.
///
/// This async function:
/// 1. Parses command-line arguments
/// 2. Calls the library's `universal_scrape` function
/// 3. Handles any errors gracefully
/// 4. Formats and outputs the results based on user preferences
///
/// # Error Handling
///
/// Errors are printed to stderr and the program exits cleanly.
/// No panics or crashes occur even if scraping fails.
///
/// # Examples
///
/// Run with basic arguments:
/// ```bash
/// # Scrape an article in English (default)
/// uninews "https://example.com/article"
///
/// # Scrape and translate to Spanish
/// uninews "https://example.com/article" --language spanish
///
/// # Get JSON output
/// uninews "https://example.com/article" --json
/// ```
async