moonbitlang / moon

The build system and package manager for MoonBit
https://moonbitlang.github.io/moon/
GNU Affero General Public License v3.0
188 stars 17 forks source link

feat: add `--no-alias` to `moon info` #474

Closed rami3l closed 1 week ago

rami3l commented 1 week ago

This corresponds to the new option -no-alias recently introduced in mooninfo:

> moon info --help
Generate public interface (`.mbti`) files for all packages in the module

Usage: moon info [OPTIONS]

Options:
  -h, --help  Print help

Manifest Options:
      --frozen    Do not sync dependencies, assuming local dependencies are up-to-date
      --no-alias  Do not use alias to shorten package names in the output

Common Options:
  -C, --directory <SOURCE_DIR>   The source code directory. Defaults to the current directory
      --target-dir <TARGET_DIR>  The target directory. Defaults to `source_dir/target`
  -q, --quiet                    Suppress output
  -v, --verbose                  Increase verbosity
      --trace                    Trace the execution of the program
      --dry-run                  Do not actually run the command
      --build-graph              Generate build graph
peter-jerry-ye-code-review[bot] commented 1 week ago

Based on the provided git diff output, here are three observations and potential issues:

  1. Unused Variable in hello.mbt:

    +pub let hello_list : @immut/list.T[String] = @immut/list.of(
    +  ["Hello, ", "world!"],
    +)

    The variable hello_list is defined but not used elsewhere in the file. This might be intentional, but if it's not, it could be a potential source of confusion or unnecessary code.

  2. Error Handling in run_info Function:

    -            let out = tokio::process::Command::new("mooninfo")
    -                .args(["-format=text", mi.display().to_string().as_str()])
    -                .output()
    -                .await?;
    +            let mut mooninfo = tokio::process::Command::new("mooninfo");
    +            mooninfo.arg("-format=text").arg(&mi);
    +            if cmd.no_alias {
    +                mooninfo.arg("-no-alias");
    +            }
    +            let out = mooninfo.output().await?;

    The new code introduces a conditional argument addition based on cmd.no_alias. However, the error handling (await?) is unchanged. Ensure that any potential errors from mooninfo.output().await? are properly handled or propagated.

  3. Removed .mbti Files:

    diff --git a/crates/moon/tests/test_cases/mbti.in/lib/lib.mbti b/crates/moon/tests/test_cases/mbti.in/lib/lib.mbti
    deleted file mode 100644
    index 64108267..00000000
    --- a/crates/moon/tests/test_cases/mbti.in/lib/lib.mbti
    +++ /dev/null
    @@ -1,11 +0,0 @@
    -package username/hello/lib
    -
    -// Values
    -fn hello() -> String
    -
    -// Types and methods
    -
    -// Traits
    -
    -// Extension Methods
    -
    diff --git a/crates/moon/tests/test_cases/mbti.in/main/main.mbti b/crates/moon/tests/test_cases/mbti.in/main/main.mbti
    deleted file mode 100644
    index 5df9ccd7..00000000
    --- a/crates/moon/tests/test_cases/mbti.in/main/main.mbti
    +++ /dev/null
    @@ -1,10 +0,0 @@
    -package username/hello/main
    -
    -// Values
    -
    -// Types and methods
    -
    -// Traits
    -
    -// Extension Methods
    -

    The .mbti files for both lib and main packages have been deleted. Ensure that these deletions are intentional and that any functionality relying on these files is appropriately updated or replaced.

These observations highlight potential issues or areas that might require further attention to ensure the code changes are both correct and efficient.