Skip to content

Commit 5d71eef

Browse files
committed
show parent title, improve docs, rename config command
1 parent 95f0009 commit 5d71eef

9 files changed

+110
-17
lines changed

README.md

+32-5
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,49 @@ A PHP application to access your Kimai 2 installation via its API (http).
88
- cURL extension
99
- json extension
1010
- iconv extension
11+
- zlib extension
1112

1213
## Installation and updates
1314

15+
To install and update the Kimai console tools, execute the following commands:
16+
1417
```bash
1518
wget curl -LJO https://github.com/kevinpapst/kimai2-console/releases/latest/download/kimai.phar
1619
chmod +x kimai.phar
1720
mv kimai.phar /usr/local/bin/kimai
1821
```
1922

20-
Now you need to create a configuration file, which is required to connect to Kimai:
23+
### Configuration file
24+
25+
Before using it the first time, you have to create a configuration file, which holds the connection infos for Kimai.
26+
By default this config file will be located at `~/.kimai2-console.json`:
27+
28+
```bash
29+
kimai configuration:create
30+
```
2131

32+
Make sure the file is only readable for your own user:
33+
2234
```bash
23-
kimai dump-configuration
35+
chmod 600 ~/.kimai2-console.json
2436
```
2537

26-
Afterwards edit the file and change the URL, username and API token to your needs.
38+
That's it, you can use Kimai from the command line now.
2739

28-
By default the configuration file targets the demo installation and will work, but this is likely not want you intent to use ;-)
40+
By default the configuration file targets the demo installation and will work... but now its time to target your own Kimai, so
41+
edit the config file and change the settings: URL, username and API token.
2942

30-
That's it, you can use Kimai now with e.g. `kimai customer:list`.
43+
## Available commands
44+
45+
You get a list of all available commands with `kimai`.
46+
47+
- `kimai customer:list` - show a list of customers
48+
- `kimai project:list` - show a list of projects
49+
- `kimai activity:list` - show a list of activities
50+
- `kimai version` - show the full version string of the remote installation
51+
- `kimai configuration:create` - creates the initial configuration file
52+
53+
To get help for a dedicated command use the `--help` switch, eg: `kimai project:list --help`
3154

3255
## Environment variables
3356

@@ -36,3 +59,7 @@ The following environment variables are supported:
3659
- `KIMAI_MEMORY_LIMIT` - configures the allowed memory limit (eg `128MB`, or `-1` for unlimited) (see [here](https://www.php.net/manual/en/ini.core.php#ini.memory-limit))
3760
- `KIMAI_CONFIG` - path to your configuration file (defaults to: $HOME/.kimai2-console.json)
3861

62+
## How to build a release
63+
64+
- Execute `box compile`
65+
-

bin/kimai

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#!/usr/bin/env php
22
<?php
33

4+
/*
5+
* This file is part of the Kimai 2 - Remote Console.
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
411
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
512
fwrite(STDERR, 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL);
613
exit(1);

src/Application.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@ protected function getDefaultCommands()
8383
new Command\ActivityListCommand(),
8484
new Command\ProjectListCommand(),
8585
new Command\CustomerListCommand(),
86-
new Command\DumpConfigurationCommand(),
86+
new Command\ConfigurationCreateCommand(),
8787
new Command\VersionCommand(),
8888
]);
8989

9090
if ('phar:' === substr(__FILE__, 0, 5)) {
91-
$commands[] = new Command\SelfUpdateCommand();
91+
// TODO commented, until it is working
92+
//$commands[] = new Command\SelfUpdateCommand();
9293
}
9394

9495
return $commands;

src/Client/Model/ActivityCollection.php

+30
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class ActivityCollection implements ModelInterface, ArrayAccess
5959
'fixed_rate' => 'float',
6060
'hourly_rate' => 'float',
6161
'color' => 'string',
62+
'parent_title' => 'string',
6263
'project' => 'int',
6364
'meta_fields' => '\KimaiConsole\Client\Model\ActivityMeta[]'
6465
];
@@ -75,6 +76,7 @@ class ActivityCollection implements ModelInterface, ArrayAccess
7576
'fixed_rate' => 'float',
7677
'hourly_rate' => 'float',
7778
'color' => null,
79+
'parent_title' => null,
7880
'project' => null,
7981
'meta_fields' => null
8082
];
@@ -112,6 +114,7 @@ public static function swaggerFormats()
112114
'fixed_rate' => 'fixedRate',
113115
'hourly_rate' => 'hourlyRate',
114116
'color' => 'color',
117+
'parent_title' => 'parentTitle',
115118
'project' => 'project',
116119
'meta_fields' => 'metaFields'
117120
];
@@ -128,6 +131,7 @@ public static function swaggerFormats()
128131
'fixed_rate' => 'setFixedRate',
129132
'hourly_rate' => 'setHourlyRate',
130133
'color' => 'setColor',
134+
'parent_title' => 'setParentTitle',
131135
'project' => 'setProject',
132136
'meta_fields' => 'setMetaFields'
133137
];
@@ -144,6 +148,7 @@ public static function swaggerFormats()
144148
'fixed_rate' => 'getFixedRate',
145149
'hourly_rate' => 'getHourlyRate',
146150
'color' => 'getColor',
151+
'parent_title' => 'getParentTitle',
147152
'project' => 'getProject',
148153
'meta_fields' => 'getMetaFields'
149154
];
@@ -210,6 +215,7 @@ public function __construct(array $data = null)
210215
$this->container['fixed_rate'] = $data['fixed_rate'] ?? null;
211216
$this->container['hourly_rate'] = $data['hourly_rate'] ?? null;
212217
$this->container['color'] = $data['color'] ?? null;
218+
$this->container['parent_title'] = $data['parent_title'] ?? null;
213219
$this->container['project'] = $data['project'] ?? null;
214220
$this->container['meta_fields'] = $data['meta_fields'] ?? null;
215221
}
@@ -403,6 +409,30 @@ public function setColor($color)
403409
return $this;
404410
}
405411

412+
/**
413+
* Gets parent_title
414+
*
415+
* @return string
416+
*/
417+
public function getParentTitle()
418+
{
419+
return $this->container['parent_title'];
420+
}
421+
422+
/**
423+
* Sets parent_title
424+
*
425+
* @param string $parent_title parent_title
426+
*
427+
* @return $this
428+
*/
429+
public function setParentTitle($parent_title)
430+
{
431+
$this->container['parent_title'] = $parent_title;
432+
433+
return $this;
434+
}
435+
406436
/**
407437
* Gets project
408438
*

src/Client/Model/ProjectCollection.php

+30
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class ProjectCollection implements ModelInterface, ArrayAccess
6060
'hourly_rate' => 'float',
6161
'color' => 'string',
6262
'customer' => 'int',
63+
'parent_title' => 'string',
6364
'meta_fields' => '\KimaiConsole\Client\Model\ProjectMeta[]'
6465
];
6566

@@ -75,6 +76,7 @@ class ProjectCollection implements ModelInterface, ArrayAccess
7576
'fixed_rate' => 'float',
7677
'hourly_rate' => 'float',
7778
'color' => null,
79+
'parent_title' => null,
7880
'customer' => null,
7981
'meta_fields' => null
8082
];
@@ -113,6 +115,7 @@ public static function swaggerFormats()
113115
'hourly_rate' => 'hourlyRate',
114116
'color' => 'color',
115117
'customer' => 'customer',
118+
'parent_title' => 'parentTitle',
116119
'meta_fields' => 'metaFields'
117120
];
118121

@@ -129,6 +132,7 @@ public static function swaggerFormats()
129132
'hourly_rate' => 'setHourlyRate',
130133
'color' => 'setColor',
131134
'customer' => 'setCustomer',
135+
'parent_title' => 'setParentTitle',
132136
'meta_fields' => 'setMetaFields'
133137
];
134138

@@ -145,6 +149,7 @@ public static function swaggerFormats()
145149
'hourly_rate' => 'getHourlyRate',
146150
'color' => 'getColor',
147151
'customer' => 'getCustomer',
152+
'parent_title' => 'getParentTitle',
148153
'meta_fields' => 'getMetaFields'
149154
];
150155

@@ -211,6 +216,7 @@ public function __construct(array $data = null)
211216
$this->container['hourly_rate'] = $data['hourly_rate'] ?? null;
212217
$this->container['color'] = $data['color'] ?? null;
213218
$this->container['customer'] = $data['customer'] ?? null;
219+
$this->container['parent_title'] = $data['parent_title'] ?? null;
214220
$this->container['meta_fields'] = $data['meta_fields'] ?? null;
215221
}
216222

@@ -403,6 +409,30 @@ public function setColor($color)
403409
return $this;
404410
}
405411

412+
/**
413+
* Gets parent_title
414+
*
415+
* @return string
416+
*/
417+
public function getParentTitle()
418+
{
419+
return $this->container['parent_title'];
420+
}
421+
422+
/**
423+
* Sets parent_title
424+
*
425+
* @param string $parent_title parent_title
426+
*
427+
* @return $this
428+
*/
429+
public function setParentTitle($parent_title)
430+
{
431+
$this->container['parent_title'] = $parent_title;
432+
433+
return $this;
434+
}
435+
406436
/**
407437
* Gets customer
408438
*

src/Command/ActivityListCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
5353

5454
$rows = [];
5555
foreach ($collection as $activity) {
56-
$project = '-';
57-
if (null !== ($prj = $activity->getProject())) {
58-
$project = $prj;
56+
$project = '';
57+
if (!empty($activity->getProject())) {
58+
$project = '[' . $activity->getProject() . '] ' . $activity->getParentTitle();
5959
}
6060
$rows[] = [
6161
$activity->getId(),

src/Command/DumpConfigurationCommand.php src/Command/ConfigurationCreateCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
use Symfony\Component\Console\Output\OutputInterface;
1515
use Symfony\Component\Console\Style\SymfonyStyle;
1616

17-
final class DumpConfigurationCommand extends BaseCommand
17+
final class ConfigurationCreateCommand extends BaseCommand
1818
{
1919
/**
2020
* {@inheritdoc}
2121
*/
2222
protected function configure()
2323
{
2424
$this
25-
->setName('dump-configuration')
26-
->setDescription('Dumps a default configuration file')
25+
->setName('configuration:create')
26+
->setDescription('Create a default configuration file')
2727
->setHelp('This command creates a default configuration file.')
2828
;
2929
}

src/Command/ProjectListCommand.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
5353

5454
$rows = [];
5555
foreach ($collection as $project) {
56-
$customer = $project->getCustomer();
57-
5856
$rows[] = [
5957
$project->getId(),
6058
$project->getName(),
61-
$project->getCustomer(),
59+
'[' . $project->getCustomer() . '] ' . $project->getParentTitle(),
6260
];
6361
}
6462
$io->table(['Id', 'Name', 'Customer ID'], $rows);

src/Constants.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Constants
1414
/**
1515
* The current release version
1616
*/
17-
public const VERSION = '0.1';
17+
public const VERSION = '0.1.1';
1818
/**
1919
* The software name
2020
*/

0 commit comments

Comments
 (0)