Skip to content

Conversation

@jdetter
Copy link
Collaborator

@jdetter jdetter commented Dec 22, 2023

Description of Changes

Please describe your change, mention any related tickets, and so on here.

  • This adds a flag --delete-files to the spacetime generate command which, when supplied, shows the user which files were not generated by us and prompts them if they would like to delete the files. We also check to see if the file starts with our auto-gen tag so that we only prompt the user to delete files that were created by us. This means they can add in their own files and we won't delete them.

When running with the new flag we get something like this:

boppy@boppy-macbook game % bash ./generate-client-files.sh 
Generating C# files
info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
checking crate with spacetimedb's clippy configuration
    Checking <project> v0.1.0 (/Users/boppy/clockwork/<project>/packages/game)
    Finished release [optimized] target(s) in 14.40s
    Finished release [optimized] target(s) in 0.10s
Optimising module with wasm-opt...
compilation took 1.433383083s
The following files were not generated by this command and will be deleted:
  ../../../<project>/Assets/_Project/autogen/File1.cs
  ../../../<project>/Assets/_Project/autogen/File2.cs
  ../../../<project>/Assets/_Project/autogen/File3.cs
Are you sure you want to delete these files? [y/N]

If you enter y or yes to this prompt it will remove the files for you. You can add --force onto the end as well if you would like to execute the removal of the files without a prompt.

API and ABI breaking changes

If this is an API or ABI breaking change, please apply the
corresponding GitHub label.

  • No API or ABI break

Expected complexity level and risk

0

How complicated do you think these changes are? Grade on a scale from 1 to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex change.

This complexity rating applies not only to the complexity apparent in the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning ways.

@jdetter jdetter changed the title Clear Flag for Generate Command Delete Files Flag for Generate Command Dec 22, 2023
@jdetter jdetter added the release-any To be landed in any release window label Dec 22, 2023
Comment on lines 159 to 162
println!("Are you sure you want to delete these files? [y/N]");
let mut input = String::new();
std::io::stdin().read_line(&mut input)?;
if input.trim().to_lowercase() == "y" || input.trim().to_lowercase() == "yes" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see a --force flag or similar which skips this check, so that generate --delete-files --force can be called in scripts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see a --force flag or similar which skips this check, so that generate --delete-files --force can be called in scripts.

Added 👍

Copy link
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions for phrasing in flag help messages. Code looks good; is clear to me.

jdetter and others added 3 commits December 22, 2023 10:27
@jdetter jdetter enabled auto-merge December 22, 2023 16:29
@jdetter jdetter added this pull request to the merge queue Dec 22, 2023
@jdetter jdetter removed this pull request from the merge queue due to a manual request Dec 22, 2023
@jdetter jdetter added this pull request to the merge queue Dec 22, 2023
Merged via the queue into master with commit e72ffcd Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-any To be landed in any release window

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants