Skip to content

Commit d63d62c

Browse files
committed
Fixed CLI
1 parent 5f09f5b commit d63d62c

2 files changed

Lines changed: 7 additions & 18 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ foreach($sessions as $session){
5858
* convert telethon.session file to LiveProto file
5959

6060
```bash
61-
php vendor/bin/sessionbridge convert --from telethon-sqlite --to liveproto-sqlite --session telethon.session
61+
php vendor/bin/sessionbridge --from telethon-sqlite --to liveproto-sqlite --session telethon.session
6262
```
6363

6464
---

bin/sessionbridge

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
declare(strict_types = 1);
55

6-
require __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
6+
require $GLOBALS['_composer_autoload_path'];
77

88
require __DIR__.DIRECTORY_SEPARATOR.'colors.php';
99

@@ -15,41 +15,30 @@ function getArgv(string $index) : ? string {
1515
}
1616

1717
function usage() : void {
18-
echo colorize(text : 'Usage : sessionbridge convert --from <format> --to <format> --session <source>',fg : 'bright_yellow',options : ['bold']) , PHP_EOL;
19-
echo colorize(text : 'Example : php vendor/bin/sessionbridge convert --from telethon-sqlite --to liveproto-sqlite --session telethon.session',fg : 'bright_blue',options : ['underline']) , PHP_EOL;
18+
echo colorize(text : 'Usage : sessionbridge --from <format> --to <format> --session <source>',fg : 'bright_yellow',options : ['bold']) , PHP_EOL;
19+
echo colorize(text : 'Example : php vendor/bin/sessionbridge --from telethon-sqlite --to liveproto-sqlite --session telethon.session',fg : 'bright_blue',options : ['underline']) , PHP_EOL;
2020
exit(1);
2121
}
2222

23-
$args = array_slice($argv,1);
24-
25-
if(count($args) === 0) usage();
26-
27-
$command = array_shift($args);
28-
29-
if($command !== 'convert'):
30-
echo colorize(text : '➥ Unknown command : '.$command,bg : 'red',options : ['bold']) , PHP_EOL;
31-
usage();
32-
endif;
33-
3423
if(is_null(getArgv('help')) === false) usage();
3524

3625
$from = str_replace(chr(45),chr(95),getArgv('from'));
3726

3827
if(function_exists('Tak\\SessionBridge\\from_'.$from) === false):
39-
echo colorize(text : '➥ Unknown from : '.$from,bg : 'red',options : ['bold']) , PHP_EOL;
28+
echo colorize(text : '➥ Unknown from : '.$from,fg : 'bright_cyan',bg : 'red',options : ['bold']) , PHP_EOL;
4029
usage();
4130
endif;
4231

4332
$to = str_replace(chr(45),chr(95),getArgv('to'));
4433

4534
if(function_exists('Tak\\SessionBridge\\to_'.$to) === false):
46-
echo colorize(text : '➥ Unknown to : '.$to,bg : 'red',options : ['bold']) , PHP_EOL;
35+
echo colorize(text : '➥ Unknown to : '.$to,fg : 'bright_cyan',bg : 'red',options : ['bold']) , PHP_EOL;
4736
usage();
4837
endif;
4938

5039
$source = getArgv('session');
5140

52-
echo colorize(text : 'ıllıllı Converting from '.$from.' to '.$to.' session',fg : 'black',bg : 'bright_yellow') , PHP_EOL;
41+
echo colorize(text : 'ıllıllı Converting from '.$from.' to '.$to.' session',fg : 'bright_magenta',bg : 'yellow') , PHP_EOL;
5342

5443
try {
5544
$sessions = call_user_func('Tak\\SessionBridge\\from_'.$from,$source);

0 commit comments

Comments
 (0)