Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flit HTML
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
Microhacks
Flit HTML
Commits
d44118cd
Verified
Commit
d44118cd
authored
2 years ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Write output
parent
1243df49
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+17
-2
17 additions, 2 deletions
src/main.rs
with
17 additions
and
2 deletions
src/main.rs
+
17
−
2
View file @
d44118cd
...
@@ -4,7 +4,7 @@ use lol_html::{element, rewrite_str, text, RewriteStrSettings};
...
@@ -4,7 +4,7 @@ use lol_html::{element, rewrite_str, text, RewriteStrSettings};
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
HashMap
;
use
std
::
fs
::
File
;
use
std
::
fs
::
File
;
use
std
::
io
::
Read
;
use
std
::
io
::
{
Read
,
Write
}
;
use
std
::
sync
::{
Arc
,
Mutex
};
use
std
::
sync
::{
Arc
,
Mutex
};
use
thiserror
::
Error
;
use
thiserror
::
Error
;
...
@@ -47,6 +47,8 @@ pub enum AppError {
...
@@ -47,6 +47,8 @@ pub enum AppError {
InvalidOpfile
(
toml
::
de
::
Error
),
InvalidOpfile
(
toml
::
de
::
Error
),
#[error(
"Failed to match selector {0}"
)]
#[error(
"Failed to match selector {0}"
)]
SelectorFailed
(
String
),
SelectorFailed
(
String
),
#[error(
"Failed to apply edits {0}"
)]
EditsFailed
(
#[from]
lol_html
::
errors
::
RewritingError
),
}
}
pub
type
AppResult
<
T
>
=
Result
<
T
,
AppError
>
;
pub
type
AppResult
<
T
>
=
Result
<
T
,
AppError
>
;
...
@@ -132,7 +134,20 @@ fn main() -> AppResult<()> {
...
@@ -132,7 +134,20 @@ fn main() -> AppResult<()> {
},
},
);
);
println!
(
"{}"
,
html
.unwrap
());
let
write_path
=
if
args
.inline
{
Some
(
args
.input
.clone
())
}
else
{
args
.output
};
if
let
Some
(
path
)
=
write_path
{
File
::
create
(
&
path
)
.map_err
(|
_
|
AppError
::
FailedToOpen
(
args
.input
.clone
()))
?
.write_all
(
html
?
.as_bytes
())
.map_err
(|
_
|
AppError
::
FailedToRead
(
args
.input
.clone
()))
?
;
}
else
{
println!
(
"{}"
,
html
?
);
}
Ok
(())
Ok
(())
}
}
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