Skip to content

Commit cdfdc3f

Browse files
authored
Merge pull request #6 from lutraconsulting/refactoring
Refactoring
2 parents 6214fef + a76ad0d commit cdfdc3f

File tree

8 files changed

+101
-259
lines changed

8 files changed

+101
-259
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/workflows/linux.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
uses: actions/checkout@v2
2020
with:
2121
repository: lutraconsulting/input
22-
ref: mergin_cpp
2322
path: input
2423

2524
- name: Checkout geodiff

.github/workflows/windows.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
uses: actions/checkout@v2
2323
with:
2424
repository: lutraconsulting/input
25-
ref: projects-model-refactoring-main
2625
path: input
2726

2827
- name: Checkout geodiff

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
src/config.pri
2+
src/client.pro.user
23

34
# Prerequisites
45
*.d

src/client.pro.user

Lines changed: 0 additions & 240 deletions
This file was deleted.

src/clientcommands.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include "clientcommands.h"
1111
#include <QEventLoop>
1212
#include <QTimer>
13+
#include <QTextStream>
14+
#include <QJsonDocument>
15+
#include <QJsonObject>
16+
1317
#include "merginuserauth.h"
1418

1519
ClientCommands::ClientCommands( const QString &dir, int timeout ):
@@ -106,6 +110,35 @@ void ClientCommands::sync()
106110
download( lp.projectNamespace, lp.projectName );
107111
}
108112

113+
void ClientCommands::info( bool isJsonFormat )
114+
{
115+
LocalProject lp = mLocalProjectsManager.projectFromDirectory( QDir::currentPath() );
116+
if ( !lp.isValid() )
117+
throw QString( "no mergin project in the current directory" );
118+
119+
QTextStream out( stdout );
120+
if ( isJsonFormat )
121+
{
122+
QJsonObject jsonData
123+
{
124+
{"name", QJsonValue( lp.projectName )},
125+
{"namespace", QJsonValue( lp.projectNamespace )},
126+
{"id", QJsonValue( lp.id() )},
127+
{"localVersion", QJsonValue( lp.localVersion )}
128+
};
129+
130+
QJsonDocument doc( jsonData );
131+
out << doc.toJson( QJsonDocument::Compact );
132+
}
133+
else
134+
{
135+
out << "name: " << lp.projectName << endl;
136+
out << "namespace: " << lp.projectNamespace << endl;
137+
out << "id: " << lp.id() << endl;
138+
out << "localVersion: " << lp.localVersion << endl;
139+
}
140+
}
141+
109142

110143
bool ClientCommands::isAuthorized()
111144
{

src/clientcommands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ClientCommands: public QObject
3131
void remove( const QString &projectNamespace, const QString &projectName );
3232
void download( const QString &projectNamespace, const QString &projectName );
3333
void sync( );
34+
void info( bool isJsonFormat );
3435

3536
private:
3637
bool isAuthorized();

0 commit comments

Comments
 (0)