Skip to content

Commit

Permalink
Show feature level
Browse files Browse the repository at this point in the history
Fix #27
  • Loading branch information
rugk committed Sep 18, 2016
1 parent 5c0f0cf commit 08cf950
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
Empty file added keystore.php
Empty file.
37 changes: 37 additions & 0 deletions source/Threema/Console/Command/FeatureLevel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* @author Threema GmbH
* @copyright Copyright (c) 2015-2016 Threema GmbH
*/

namespace Threema\Console\Command;

use Threema\Console\Common;
use Threema\MsgApi\Tools\CryptTool;

class FeatureLevel extends Base {
/**
* @param PublicKeyStore $publicKeyStore
*/
public function __construct() {
parent::__construct('Show current feature level',
[],
'Show current version and feature level');
}

protected function doRun() {
$cryptTool = CryptTool::getInstance();

Common::l('Version: '.MSGAPI_SDK_VERSION);
Common::l('Feature level: '.MSGAPI_SDK_FEATURE_LEVEL);
Common::l('CryptTool: '.$cryptTool->getName().' ('.$cryptTool->getDescription().')');

Common::l(' ╔═══════╤══════╤══════════════╤═══════╤══════╤═════════╗');
Common::l(' ║ Level │ Text │ Capabilities │ Image │ File │ Credits ║');
Common::l(' ╟───────┼──────┼──────────────┼───────┼──────┼─────────╢');
Common::l(' ║ 1 │ X │ │ │ │ ║');
Common::l(' ║ 2 │ X │ X │ X │ X │ ║');
Common::l("\033[1;32m\033[40m▶".'║ 3 │ X │ X │ X │ X │ X ║'."\033[0m");
Common::l(' ╚═══════╧══════╧══════════════╧═══════╧══════╧═════════╝');
}
}
5 changes: 4 additions & 1 deletion source/Threema/Console/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Threema\Console\Command\SendE2EText;
use Threema\Console\Command\SendSimple;
use Threema\Console\Command\Credits;
use Threema\Console\Command\FeatureLevel;
use Threema\Core\Exception;
use Threema\MsgApi\PublicKeyStore;
use Threema\MsgApi\Tools\CryptTool;
Expand Down Expand Up @@ -70,6 +71,7 @@ public function __construct(array $arguments, PublicKeyStore $publicKeyStore) {
$this->register(array('-h', '-p'), new HashPhone());
$this->register('-g', new GenerateKeyPair());
$this->register('-d', new DerivePublicKey());
$this->register('-v', new FeatureLevel());

$this->registerSubject('Network operations');
//network operations
Expand Down Expand Up @@ -160,7 +162,8 @@ private function help() {
Common::l();
Common::l('Threema PHP MsgApi Tool');
Common::l('Version: '.MSGAPI_SDK_VERSION);
Common::l('CryptTool: '.$defaultCryptTool->getName().' '.$defaultCryptTool->getDescription());
Common::l('Feature level: '.MSGAPI_FEATURE_LEVEL);
Common::l('CryptTool: '.$defaultCryptTool->getName().' ('.$defaultCryptTool->getDescription().')');
Common::l(str_repeat('.', 40));
Common::l();
foreach($this->commands as $data) {
Expand Down
2 changes: 2 additions & 0 deletions source/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

$sdkVersion = '1.1.7';
define('MSGAPI_SDK_VERSION', $sdkVersion);
$sdkFeatLevel = 3;
define('MSGAPI_SDK_FEATURE_LEVEL', $sdkFeatLevel);
$cryptTool = Threema\MsgApi\Tools\CryptTool::getInstance();

if(null === $cryptTool) {
Expand Down
5 changes: 3 additions & 2 deletions threema-msgapi-tool.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/php
#!/usr/bin/env php
<?php
/**
* @author Threema GmbH
Expand All @@ -12,7 +12,8 @@
'To use the threema msgapi sdk in your web project, include the source/bootstrap.php or the threema_msgapi.phar file.');
}
try {
include 'threema_msgapi.phar';
include 'source/bootstrap.php';
// include 'threema_msgapi.phar';

$tool = new \Threema\Console\Run(
$argv,
Expand Down

0 comments on commit 08cf950

Please sign in to comment.