(29.01.2026 tarihinde oluşturuldu.)
Bağımlılık eklemek için pubspec.yaml dosyası içerisinde dependencies kısmı altına ilgili paket ismi yazılır.
dependencies:
http: ^1.3.0dart pub getimport 'package:http/http.dart' as http; // Add this lineFuture<String> getWikipediaArticle(String articleTitle) async {
final client = http.Client(); // Create an HTTP client
final url = Uri.https(
'en.wikipedia.org', // Wikipedia API domain
'/api/rest_v1/page/summary/$articleTitle', // API path for article summary
);
// ...
}// ... (beginning of searchWikipedia function, after determining articleTitle)
void searchWikipedia(List<String>? arguments) async {
late String? articleTitle;
if (arguments == null || arguments.isEmpty) {
print('Please provide an article title.');
final inputFromStdin = stdin.readLineSync();
if (inputFromStdin == null || inputFromStdin.isEmpty) {
print('No article title provided. Exiting.');
return;
}
articleTitle = inputFromStdin;
} else {
articleTitle = arguments.join(' ');
}
print('Looking up articles about "$articleTitle". Please wait.');
// Call the API and await the result
var articleContent = await getWikipediaArticle(articleTitle);
print(articleContent); // Print the full article response (raw JSON for now)
}// ... (existing const version declaration and printUsage function)
void main(List<String> arguments) {
if (arguments.isEmpty || arguments.first == 'help') {
printUsage();
} else if (arguments.first == 'version') {
print('Dartpedia CLI version $version');
} else if (arguments.first == 'wikipedia') { // Changed to 'wikipedia'
// Pass all arguments *after* 'wikipedia' to searchWikipedia
final inputArgs = arguments.length > 1 ? arguments.sublist(1) : null;
searchWikipedia(inputArgs); // Call searchWikipedia (no 'await' needed here for main)
} else {
printUsage(); // Catch all for any unrecognized command.
}
print("Fonksiyon kapandı");
}$ dart run bin/cli.dart wikipedia Hacking
Fonksiyon kapandı
{"type":"disambiguation",
"title":"Hacking",
"displaytitle":"<span class=\"mw-page-title-main\">Hacking</span>",
"namespace":{"id":0,"text":""},
"wikibase_item":"Q180371",
"titles":{"canonical":"Hacking","normalized":"Hacking","display":"<span class=\"mw-page-title-main\">Hacking</span>"},
"pageid":13192,
"lang":"en",
"dir":"ltr",
"revision":"1298343912",
"tid":"40dc94b9-56cc-11f0-8f09-e0c5e010eef5",
"timestamp":"2025-07-01T22:39:31Z",
"description":"Topics referred to by the same term",
"description_source":"local",
"content_urls":{"desktop":{"page":"https://en.wikipedia.org/wiki/Hacking","revisions":"https://en.wikipedia.org/wiki/Hacking?action=history","edit":"https://en.wikipedia.org/wiki/Hacking?action=edit","talk":"https://en.wikipedia.org/wiki/Talk:Hacking"},
"mobile":{"page":"https://en.wikipedia.org/wiki/Hacking","revisions":"https://en.wikipedia.org/wiki/Special:History/Hacking","edit":"https://en.wikipedia.org/wiki/Hacking?action=edit","talk":"https://en.wikipedia.org/wiki/Talk:Hacking"}},
"extract":"Hacking may refer to:",
"extract_html":"<p><b>Hacking</b> may refer to:</p>"}