| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | namespace Clansuite\Capture\CLI; |
| 14: | |
| 15: | use function in_array; |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | class HelpCommand |
| 21: | { |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public function run(array $argv): int |
| 30: | { |
| 31: | |
| 32: | |
| 33: | |
| 34: | $maybe = $argv[1] ?? ''; |
| 35: | $helpFlags = ['-h', '--help', 'help', null, '']; |
| 36: | |
| 37: | $prefix = in_array($maybe, $helpFlags, true) ? '' : $maybe; |
| 38: | |
| 39: | $this->printHelp($prefix); |
| 40: | |
| 41: | return 0; |
| 42: | } |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public function printHelp(string $prefix = ''): void |
| 50: | { |
| 51: | if ($prefix !== '') { |
| 52: | print $prefix; |
| 53: | } |
| 54: | |
| 55: | print "Clansuite Server Query - Capture Tool CLI\n"; |
| 56: | print "Copyright (c) 2003-2025 Jens A. Koch.\n"; |
| 57: | print "License: MIT.\n"; |
| 58: | print "\n"; |
| 59: | print "Description:\n"; |
| 60: | print " A command-line tool to query and capture information from supported game servers.\n"; |
| 61: | print "\n"; |
| 62: | print "Usage:\n"; |
| 63: | print " capture <ip> <query_port> [protocol] # Captures a fixture from server and stores it.\n"; |
| 64: | print " capture list # Lists available fixtures.\n"; |
| 65: | print " capture help|-h|--help # Shows this message.\n"; |
| 66: | print "\n"; |
| 67: | print "Arguments:\n"; |
| 68: | print " <ip> IP address or hostname of the game server\n"; |
| 69: | print " <port> Port number of the game server\n\n"; |
| 70: | print "\n"; |
| 71: | print "Examples:\n"; |
| 72: | print " capture ger10.ddnet.org 8300 ddnet\n"; |
| 73: | print " capture 123.123.123.123 8303 arma3\n"; |
| 74: | print " capture list\n"; |
| 75: | print " capture list ddnet | jq '.' # filter and pretty-print ddnet captures\n"; |
| 76: | print "\n"; |
| 77: | print "Notes:\n"; |
| 78: | print " - Use -h or --help to show this message.\n"; |
| 79: | } |
| 80: | } |
| 81: | |