Skip to content

feat(cli): add clone command to download a standalone project#137

Merged
andrius-puksta-sensmetry merged 30 commits intomainfrom
ap/clone-project
Dec 12, 2025
Merged

feat(cli): add clone command to download a standalone project#137
andrius-puksta-sensmetry merged 30 commits intomainfrom
ap/clone-project

Conversation

@andrius-puksta-sensmetry
Copy link
Copy Markdown
Collaborator

@andrius-puksta-sensmetry andrius-puksta-sensmetry commented Dec 4, 2025

Changes

$ sysand clone --help
Clone a project to a specified directory.
Equivalent to manually downloading, extracting the
project to the directory and running `sysand sync`

Usage: sysand clone [OPTIONS] <LOCATOR|--iri <IRI>|--path <PATH>>

Arguments:
  [LOCATOR]  Clone the project from a given locator, trying to parse it as an
             IRI/URI/URL and otherwise falling back to using it as a path

Options:
  -i, --iri <IRI>          IRI/URI/URL identifying the project to be cloned [aliases: --uri, --url]
  -s, --path <PATH>        Path to clone the project from
  -t, --target <TARGET>    Path to clone the project into. If already exists, must
                           be an empty directory. Defaults to current directory
  -V, --version <VERSION>  Version of the project to clone. Defaults to the latest
                           version according to SemVer 2.0
      --no-deps            Don't resolve or install dependencies

Resolution options:
      --index [<INDEX>...]
          Comma-delimited list of index URLs to use when resolving
          project(s) and/or their dependencies, in addition to the default indexes. [env: SYSAND_INDEX=]
      --default-index [<DEFAULT_INDEX>...]
          Comma-delimited list of URLs to use as default index
          URLs. Default indexes are tried before other indexes
          (default `https://beta.sysand.org`) [env: SYSAND_DEFAULT_INDEX=]
      --no-index
          Do not use any index when resolving project(s) and/or their dependencies
      --include-std
          Don't ignore KerML/SysML v2 standard libraries if specified as dependencies

Global options:
[...]

Installing a project with std lib deps:

$ sysand clone urn:kpar:systems-library
     Cloning project with IRI `urn:kpar:systems-library` to
             `/path/to/current/dir`
      Cloned `SysML Systems Library` 2.0.0
warning: Direct or transitive usages of SysML v2/KerML standard library packages are
         ignored by default. If you want to process them, pass `--include-std` flag
    Creating env
     Syncing env
$ sysand clone urn:kpar:systems-library --include-std
     Cloning project with IRI `urn:kpar:systems-library` to
             `/path/to/current/dir`
      Cloned `SysML Systems Library` 2.0.0
    Creating env
     Syncing env
  Installing `urn:kpar:data-type-library` 1.0.0
  Installing `urn:kpar:function-library` 1.0.0
  Installing `urn:kpar:semantic-library` 1.0.0

Cloning from path:

$ sysand clone /path/to/project
     Cloning project from `/path/to/project` to
             `/path/to/current/dir`
      Cloned `project name` X.Y.Z
    Creating env
     Syncing env

The project is directly cloned into the target directory. Any created files/dirs are cleaned up on failure.

  • make clone_project return project's info and metadata, as it's free

Fixes

  • make dependency solver choose latest valid version
  • make env install choose latest valid version if none is specified
  • use Option::ok_or_else() instead of ok_or() for error reporting to avoid unnecessary work in happy path
  • reduce use of unwrap. Part of Consider replacing panics with internal errors #110.

Doc book updates will be done in a subsequent PR to reduce PR sizes.

…ok_or_else() instead of `ok_or()` to avoid unnecessary work in happy path

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>

fixes, formatting

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>

more file scheme tests

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>

a

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
…ommand

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
…e instead of taking a String and then maybe converting it to Iri at some later point

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
…fer to any dependencies, direct or indirect

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
…ere possible

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
…ble if none is given, add error bound to all errors that matches anyhow's bound for convenience

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
It was unused, incurred an allocation and could easily be
obtained by users of lock functions anyway.

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
@andrius-puksta-sensmetry
Copy link
Copy Markdown
Collaborator Author

PR is done and waiting for final review.

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
…ets mistaken for locator)

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@victor-linroth-sensmetry
Copy link
Copy Markdown
Collaborator

A basic integration test shouldn't be too much hassle to add.

…if dependency resolution fails

Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
@andrius-puksta-sensmetry
Copy link
Copy Markdown
Collaborator Author

Added some integration tests for sysand clone.

@andrius-puksta-sensmetry andrius-puksta-sensmetry merged commit 6a496ba into main Dec 12, 2025
51 checks passed
@andrius-puksta-sensmetry andrius-puksta-sensmetry deleted the ap/clone-project branch December 12, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement "editable" mode

3 participants