Profile bindings (#55)

* basic framework. still has errors

* added functionality for main endpoints + some structuring

* formatting

* unused code

* mimicked CLI function with wait_for process

* made PR changes, added playground

* cargo fmt

* removed missed println

* misc tests fixes

* cargo fmt

* added windows support

* cargo fmt

* all OS use dunce

* restructured profile slightly; fixed mac bug

* profile changes, new main.rs

* fixed requested pr + canonicaliation bug

* fixed regressed bug in ui

* fixed regressed bugs

* fixed git error

* typo

* ran prettier

* clippy

* playground clippy

* ported profile loading fix

* profile change for real, url println and clippy

* PR changes

---------

Co-authored-by: Wyatt <wyatt@modrinth.com>
This commit is contained in:
Wyatt Verchere
2023-03-31 11:00:43 -07:00
committed by GitHub
parent 24ba986cf1
commit f48959a816
30 changed files with 857 additions and 80 deletions

View File

@@ -3,6 +3,7 @@ use crate::util::{
confirm_async, prompt_async, select_async, table, table_path_display,
};
use daedalus::modded::LoaderVersion;
use dunce::canonicalize;
use eyre::{ensure, Result};
use futures::prelude::*;
use paris::*;
@@ -50,7 +51,7 @@ impl ProfileAdd {
self.profile.display()
);
let profile = self.profile.canonicalize()?;
let profile = canonicalize(&self.profile)?;
let json_path = profile.join("profile.json");
ensure!(
@@ -137,7 +138,7 @@ impl ProfileInit {
}
info!(
"Creating profile at path {}",
&self.path.canonicalize()?.display()
&canonicalize(&self.path)?.display()
);
// TODO: abstract default prompting
@@ -343,7 +344,7 @@ impl ProfileRemove {
_args: &crate::Args,
_largs: &ProfileCommand,
) -> Result<()> {
let profile = self.profile.canonicalize()?;
let profile = canonicalize(&self.profile)?;
info!("Removing profile {} from Theseus", self.profile.display());
if confirm_async(String::from("Do you wish to continue"), true).await? {
@@ -382,7 +383,7 @@ impl ProfileRun {
_largs: &ProfileCommand,
) -> Result<()> {
info!("Starting profile at path {}...", self.profile.display());
let path = self.profile.canonicalize()?;
let path = canonicalize(&self.profile)?;
ensure!(
profile::is_managed(&path).await?,
@@ -402,7 +403,8 @@ impl ProfileRun {
.await?;
let credentials = auth::refresh(id, false).await?;
let mut proc = profile::run(&path, &credentials).await?;
let proc_lock = profile::run(&path, &credentials).await?;
let mut proc = proc_lock.write().await;
profile::wait_for(&mut proc).await?;
success!("Process exited successfully!");