snarkvm_debug/cli/commands/build.rs
1// Copyright (C) 2019-2023 Aleo Systems Inc.
2// This file is part of the snarkVM library.
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at:
7// http://www.apache.org/licenses/LICENSE-2.0
8
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use super::*;
16
17/// Compiles an Aleo program.
18#[derive(Debug, Parser)]
19pub struct Build {
20 /// Uses the specified endpoint.
21 #[clap(long)]
22 endpoint: Option<String>,
23 /// Toggles offline mode.
24 #[clap(long)]
25 offline: bool,
26}
27
28impl Build {
29 /// Compiles an Aleo program with the specified name.
30 pub fn parse(self) -> Result<String> {
31 // Derive the program directory path.
32 let path = std::env::current_dir()?;
33
34 // Load the package.
35 let package = Package::open(&path)?;
36
37 println!("⚠️ Attention - This command is deprecated. Use the {} command.\n", "'run'".to_string().bold());
38
39 // Build the package, if the package requires building.
40 package.build::<Aleo>(self.endpoint)?;
41
42 // package.build::<Aleo>(match self.offline {
43 // true => None,
44 // false => Some(endpoint.unwrap_or("https://vm.aleo.org/testnet3/build".to_string())),
45 // })?;
46
47 // Prepare the path string.
48 let path_string = format!("(in \"{}\")", path.display());
49
50 // Log the build as successful.
51 Ok(format!("✅ Built '{}' {}", package.program_id().to_string().bold(), path_string.dimmed()))
52 }
53}