forked from noir-lang/noir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nargo): Stubbed out debug repl with placeholder command
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use clap::Args; | ||
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; | ||
use noirc_driver::CompileOptions; | ||
use noirc_frontend::graph::CrateName; | ||
use crate::backends::Backend; | ||
use crate::errors::CliError; | ||
use super::NargoConfig; | ||
|
||
use reedline_repl_rs::clap::{ | ||
Arg as ReplArg, | ||
ArgMatches as ReplArgMatches, | ||
Command as ReplCommand, | ||
}; | ||
use reedline_repl_rs::{Repl, Result as ReplResult}; | ||
|
||
/// Launches an interactve shell for debugging | ||
#[derive(Debug, Clone, Args)] | ||
pub(crate) struct DebugCommand { | ||
/// The name of the package to detail | ||
#[clap(long, conflicts_with = "workspace")] | ||
package: Option<CrateName>, | ||
|
||
/// Detail all packages in the workspace | ||
#[clap(long, conflicts_with = "package")] | ||
workspace: bool, | ||
|
||
#[clap(flatten)] | ||
compile_options: CompileOptions, | ||
} | ||
|
||
pub(crate) fn run( | ||
_backend: &Backend, | ||
args: DebugCommand, | ||
config: NargoConfig, | ||
) -> Result<(), CliError> { | ||
let toml_path = get_package_manifest(&config.program_dir)?; | ||
let default_selection = | ||
if args.workspace { PackageSelection::All } else { PackageSelection::DefaultOrAll }; | ||
let selection = args.package.map_or(default_selection, PackageSelection::Selected); | ||
let _workspace = resolve_workspace_from_toml(&toml_path, selection)?; | ||
|
||
let mut repl = Repl::new(()) | ||
.with_name("debug") | ||
.with_version(env!["CARGO_PKG_VERSION"]) | ||
.with_command( | ||
ReplCommand::new("placeholder") | ||
.arg(ReplArg::new("x").required(true)) | ||
.about("placeholer command. remove me!"), | ||
placeholder, | ||
); | ||
repl.run().unwrap(); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn placeholder<T>(args: ReplArgMatches, _context: &mut T) -> ReplResult<Option<String>> { | ||
Ok(Some(format!( | ||
"placeholder. x={}", | ||
args.get_one::<String>("x").unwrap() | ||
))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters