Skip to content

Commit

Permalink
generator: remove redundant flag (#1952)
Browse files Browse the repository at this point in the history
With the configlet wrapper added in
#1950, the `--offline` flag is now
always set.
  • Loading branch information
senekor authored Aug 13, 2024
1 parent e6c6861 commit d7b5cd7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 32 deletions.
2 changes: 1 addition & 1 deletion rust-tooling/ci-tests/tests/stubs_are_warning_free.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn stubs_are_warning_free() {
.unwrap()
.map(Result::unwrap)
{
if std::fs::read_to_string(&manifest.parent().unwrap().join(".meta").join("config.json"))
if std::fs::read_to_string(manifest.parent().unwrap().join(".meta").join("config.json"))
.unwrap()
.contains("allowed-to-not-compile")
{
Expand Down
10 changes: 0 additions & 10 deletions rust-tooling/generate/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,12 @@ pub struct AddArgs {

#[arg(short, long)]
difficulty: Option<Difficulty>,

/// do not update problem-specifications cache
#[arg(long)]
offline: bool,
}

pub struct FullAddArgs {
pub slug: String,
pub name: String,
pub difficulty: track_config::Difficulty,
pub offline: bool,
}

impl AddArgs {
Expand All @@ -69,7 +64,6 @@ impl AddArgs {
slug,
name,
difficulty,
offline: self.offline,
})
}
}
Expand All @@ -79,10 +73,6 @@ pub struct UpdateArgs {
/// slug of the exercise to update
#[arg(short, long)]
slug: Option<String>,

/// do not update problem-specifications cache
#[arg(long)]
pub offline: bool,
}

impl UpdateArgs {
Expand Down
36 changes: 15 additions & 21 deletions rust-tooling/generate/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fn add_exercise(args: AddArgs) -> Result<()> {
slug,
name,
difficulty,
offline,
} = args.unwrap_args_or_prompt()?;

let config = track_config::PracticeExercise::new(slug.clone(), name, difficulty);
Expand All @@ -42,40 +41,35 @@ Added your exercise to config.json.
You can add practices, prerequisites and topics if you like."
);

make_configlet_generate_what_it_can(&slug, offline)?;
make_configlet_generate_what_it_can(&slug)?;

let is_update = false;
generate_exercise_files(&slug, is_update)
}

fn update_exercise(args: UpdateArgs) -> Result<()> {
let offline = args.offline;
let slug = args.unwrap_slug_or_prompt()?;

make_configlet_generate_what_it_can(&slug, offline)?;
make_configlet_generate_what_it_can(&slug)?;

let is_update = true;
generate_exercise_files(&slug, is_update)
}

fn make_configlet_generate_what_it_can(slug: &str, offline: bool) -> Result<()> {
fn make_configlet_generate_what_it_can(slug: &str) -> Result<()> {
let status = std::process::Command::new("just")
.args(
[
"configlet",
"sync",
"--update",
"--yes",
"--docs",
"--metadata",
"--tests",
"include",
"--exercise",
slug,
]
.into_iter()
.chain(offline.then_some("--offline")),
)
.args([
"configlet",
"sync",
"--update",
"--yes",
"--docs",
"--metadata",
"--tests",
"include",
"--exercise",
slug,
])
.status()
.context("failed to run configlet sync")?;
if !status.success() {
Expand Down

0 comments on commit d7b5cd7

Please sign in to comment.