-
Notifications
You must be signed in to change notification settings - Fork 10
/
liferaft
96 lines (79 loc) · 2.11 KB
/
liferaft
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
#!/usr/bin/env php
<?php
if (file_exists(__DIR__.'/vendor/autoload.php'))
{
require __DIR__.'/vendor/autoload.php';
}
else
{
require __DIR__.'/../../autoload.php';
}
/**
* Get The Github Token...
*/
$token = null;
if (file_exists($config = __DIR__.'/liferaft.json'))
{
$token = json_decode(file_get_contents($config), true)['token'];
}
/**
* Create A Container Instance...
*/
$container = new Illuminate\Container\Container;
/**
* Imports...
*/
use Psr\Log\LogLevel;
use Illuminate\Events\Dispatcher;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Configure The Console Output...
*/
$container->bindShared('output', function()
{
return new ConsoleOutput;
});
/**
* Configure The Logger Implementation...
*/
$container->bindShared('Illuminate\Events\Dispatcher', function($container)
{
$dispatcher = new Dispatcher($container);
$dispatcher->listen('write', function($message) use ($container)
{
$container['output']->write($message);
});
$dispatcher->listen('line', function($message) use ($container)
{
$container['output']->writeln($message);
});
return $dispatcher;
});
/**
* Configure The Github Client...
*/
$container->bindShared('Github\Client', function() use ($token)
{
$client = new Github\Client;
$client->authenticate($token, null, Github\Client::AUTH_HTTP_TOKEN);
return $client;
});
/**
* Configure The Github Contract
*/
$container->bindShared('Laravel\Liferaft\Contracts\Github', function($container)
{
return new Laravel\Liferaft\Services\KnpGithub($container['Github\Client'], $container['Illuminate\Events\Dispatcher']);
});
/**
* Bootstrap The Console Application
*/
$app = new Symfony\Component\Console\Application('Laravel Liferaft', '1.0.0');
$app->add($container->make('Laravel\Liferaft\NewCommand'));
$app->add($container->make('Laravel\Liferaft\ThrowCommand'));
$app->add($container->make('Laravel\Liferaft\DestroyCommand'));
$app->add($container->make('Laravel\Liferaft\GrabCommand'));
$app->add($container->make('Laravel\Liferaft\AuthCommand'));
$app->run();