Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Enzo Cioppettini
ion
Commits
1f657c8e
Commit
1f657c8e
authored
9 years ago
by
Benjamin Elliott
Browse files
Options
Downloads
Patches
Plain Diff
Avoid using _unused
Use the result information to catch bad commands before running them
parent
22231418
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib.rs
+15
-11
15 additions, 11 deletions
src/lib.rs
with
15 additions
and
11 deletions
src/lib.rs
+
15
−
11
View file @
1f657c8e
...
...
@@ -6,16 +6,20 @@ use command::*;
pub
fn
repl
()
{
let
mut
input
=
String
::
new
();
let
_unused
=
io
::
stdin
()
.read_line
(
&
mut
input
);
let
out_wrap
=
run
(
input
.trim
()
.split_whitespace
()
.collect
::
<
Vec
<&
str
>>
());
if
out_wrap
.is_some
()
{
let
out
=
out_wrap
.unwrap
();
if
out
.stdout
.is_empty
()
{
println!
(
"{}"
,
out
.stderr
.trim
());
}
else
{
println!
(
"{}"
,
out
.stdout
.trim
());
match
io
::
stdin
()
.read_line
(
&
mut
input
)
{
Ok
(
n
)
=>
{
let
out_wrap
=
run
(
input
.trim
()
.split_whitespace
()
.collect
::
<
Vec
<&
str
>>
());
if
out_wrap
.is_some
()
{
let
out
=
out_wrap
.unwrap
();
if
out
.stdout
.is_empty
()
{
println!
(
"{}"
,
out
.stderr
.trim
());
}
else
{
println!
(
"{}"
,
out
.stdout
.trim
());
}
}
else
{
println!
(
"{} is not a valid command"
,
input
.trim
());
}
}
}
else
{
println!
(
"{} is not a valid command"
,
input
.trim
());
}
Err
(
error
)
=>
println!
(
"Line Read Error: {}"
,
error
)
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment