Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
UERANSIM
Commits
25ab36e0
Commit
25ab36e0
authored
Feb 13, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CLI executable improvement
parent
5bc0ea58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
src/cli.cpp
src/cli.cpp
+12
-7
No files found.
src/cli.cpp
View file @
25ab36e0
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
#include <iostream>
#include <iostream>
#include <set>
#include <set>
#include <string>
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_map>
#include <utils/common.hpp>
#include <utils/common.hpp>
#include <utils/constants.hpp>
#include <utils/constants.hpp>
...
@@ -161,18 +160,20 @@ static void ReadOptions(int argc, char **argv)
...
@@ -161,18 +160,20 @@ static void ReadOptions(int argc, char **argv)
}
}
}
}
static
void
HandleMessage
(
const
app
::
CliMessage
&
msg
,
bool
isOneShot
)
static
bool
HandleMessage
(
const
app
::
CliMessage
&
msg
,
bool
isOneShot
)
{
{
if
(
msg
.
type
==
app
::
CliMessage
::
Type
::
ERROR
)
if
(
msg
.
type
==
app
::
CliMessage
::
Type
::
ERROR
)
{
{
std
::
cerr
<<
"ERROR: "
<<
msg
.
value
<<
std
::
endl
;
std
::
cerr
<<
"ERROR: "
<<
msg
.
value
<<
std
::
endl
;
if
(
isOneShot
)
if
(
isOneShot
)
exit
(
1
);
exit
(
1
);
return
true
;
}
}
if
(
msg
.
type
==
app
::
CliMessage
::
Type
::
ECHO
)
if
(
msg
.
type
==
app
::
CliMessage
::
Type
::
ECHO
)
{
{
std
::
cout
<<
msg
.
value
<<
std
::
endl
;
std
::
cout
<<
msg
.
value
<<
std
::
endl
;
return
true
;
}
}
if
(
msg
.
type
==
app
::
CliMessage
::
Type
::
RESULT
)
if
(
msg
.
type
==
app
::
CliMessage
::
Type
::
RESULT
)
...
@@ -180,7 +181,10 @@ static void HandleMessage(const app::CliMessage &msg, bool isOneShot)
...
@@ -180,7 +181,10 @@ static void HandleMessage(const app::CliMessage &msg, bool isOneShot)
std
::
cout
<<
msg
.
value
<<
std
::
endl
;
std
::
cout
<<
msg
.
value
<<
std
::
endl
;
if
(
isOneShot
)
if
(
isOneShot
)
exit
(
0
);
exit
(
0
);
return
true
;
}
}
return
false
;
}
}
[[
noreturn
]]
static
void
SendCommand
(
uint16_t
port
)
[[
noreturn
]]
static
void
SendCommand
(
uint16_t
port
)
...
@@ -189,20 +193,21 @@ static void HandleMessage(const app::CliMessage &msg, bool isOneShot)
...
@@ -189,20 +193,21 @@ static void HandleMessage(const app::CliMessage &msg, bool isOneShot)
if
(
g_options
.
directCmd
.
empty
())
if
(
g_options
.
directCmd
.
empty
())
{
{
std
::
thread
receiver
{[
&
server
]()
{
while
(
true
)
HandleMessage
(
server
.
receiveMessage
(),
false
);
}};
while
(
true
)
while
(
true
)
{
{
std
::
string
line
{};
std
::
string
line
{};
std
::
cout
<<
">> "
;
std
::
getline
(
std
::
cin
,
line
);
std
::
getline
(
std
::
cin
,
line
);
if
(
!
std
::
cin
)
if
(
!
std
::
cin
)
exit
(
0
);
exit
(
0
);
server
.
sendMessage
(
server
.
sendMessage
(
app
::
CliMessage
::
Command
(
InetAddress
{
cons
::
CMD_SERVER_IP
,
port
},
line
,
g_options
.
nodeName
));
app
::
CliMessage
::
Command
(
InetAddress
{
cons
::
CMD_SERVER_IP
,
port
},
line
,
g_options
.
nodeName
));
while
(
!
HandleMessage
(
server
.
receiveMessage
(),
false
))
{
// empty
}
}
}
}
}
else
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment