Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
create-prog-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iliya.saroukha
create-prog-app
Commits
f47c039b
Commit
f47c039b
authored
2 years ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
finished exam template function
parent
13523003
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+64
-2
64 additions, 2 deletions
src/main.rs
with
64 additions
and
2 deletions
src/main.rs
+
64
−
2
View file @
f47c039b
...
...
@@ -7,7 +7,7 @@ use std::fs::{create_dir, File};
use
std
::
io
::
Write
;
use
std
::
path
::
PathBuf
;
pub
fn
algo_template
()
{
fn
algo_template
()
{
let
current_dir
=
env
::
current_dir
()
.expect
(
"Failed at locating current directory"
);
let
mut
root
=
PathBuf
::
new
();
...
...
@@ -90,7 +90,69 @@ pub fn algo_template() {
.expect
(
&
format!
(
"Not able to write to {}"
,
impl_filename
));
}
fn
exam_template
()
{}
fn
exam_template
()
{
let
current_dir
=
env
::
current_dir
()
.expect
(
"Failed at locating current directory"
);
let
mut
root
=
PathBuf
::
new
();
root
.push
(
current_dir
);
let
mut
project_name
=
String
::
from
(
"prog_seq_exam_"
);
print!
(
"
\n
Please specify the month: "
);
let
month
=
from_stdin
::
input_from_stdin
();
project_name
.push_str
(
&
month
);
root
.push
(
project_name
);
create_dir
(
&
root
)
.expect
(
&
format!
(
"Failed at creating {} directory"
,
root
.display
()));
print!
(
"
\n
Please specify the number of exercices: "
);
let
nb_exercices
=
from_stdin
::
input_from_stdin
()
.parse
::
<
u8
>
()
.expect
(
"Please input an integer!"
);
for
i
in
1
..
nb_exercices
+
1
{
let
mut
exam_subdir
=
String
::
from
(
"ex"
);
exam_subdir
.push_str
(
format!
(
"{}"
,
i
)
.as_str
());
let
mut
main_filename
=
exam_subdir
.clone
();
main_filename
.push_str
(
".c"
);
root
.push
(
exam_subdir
);
create_dir
(
&
root
)
.expect
(
&
format!
(
"Failed at creating {} directory"
,
root
.display
()));
let
mut
main_file
=
File
::
create
(
&
(
root
.to_owned
()
.into_os_string
()
.into_string
()
.unwrap
()
+
"/"
+
&
main_filename
),
)
.expect
(
&
format!
(
"Cannot create '{}' file"
,
main_filename
));
main_file
.write_all
(
code_templates
::
template_for_examfile
()
.to_string
()
.as_bytes
(),
)
.expect
(
&
format!
(
"Not able to write to {}"
,
main_filename
));
let
mut
makefile
=
File
::
create
(
&
(
root
.to_owned
()
.into_os_string
()
.into_string
()
.unwrap
()
+
"/"
+
"Makefile"
),
)
.expect
(
"Cannot create Makefile!"
);
makefile
.write_all
(
code_templates
::
template_for_makefile_exam
(
main_filename
)
.to_string
()
.as_bytes
(),
)
.expect
(
"Not able to write to Makefile"
);
root
.pop
();
}
}
fn
main
()
{
to_stdout
::
print_menu
();
...
...
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