Skip to content

Commit

Permalink
Ignore doctest and ran cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
humblepenguinn committed Mar 20, 2024
1 parent 18ca064 commit cda0c54
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 124 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readme = "README.md"
[lib]
name = "envio"
path = "src/lib.rs"
doctest = false

[dependencies]
age = "0.9.1"
Expand Down
32 changes: 15 additions & 17 deletions src/bin/envio/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// Utility/helper functions specific to the CLI version of envio.
/// These functions are designed for CLI usage and may not be something used by users interacting with the API directly

use std::{
collections::HashMap,
io::{Read, Write},
Expand Down Expand Up @@ -29,7 +28,7 @@ use crate::utils::get_shell_config;
/// - `name` - the name of the profile
/// - `envs` - the environment variables of the profile
/// - `encryption_type` - the encryption type of the profile
///
///
/// # Returns
/// - `Result<()>`: whether the operation was successful
pub fn create_profile(
Expand Down Expand Up @@ -84,12 +83,12 @@ pub fn create_profile(
}

/// Export all the environment variables of the profile to a file in plain text
///
///
/// # Parameters
/// - `profile` - the profile to export ([Profile] object)
/// - `file_name` - the name of the file to export to
/// - `envs_selected` - the environment variables to export
///
///
/// # Returns
/// - `Result<()>`: whether the operation was successful
pub fn export_envs(
Expand Down Expand Up @@ -144,7 +143,7 @@ pub fn export_envs(
}

/// List the environment variables stored in a profile
///
///
/// # Parameters
/// - `profile` - the profile to list the environment variables of ([Profile] object)
pub fn list_envs(profile: &Profile) {
Expand All @@ -162,10 +161,10 @@ pub fn list_envs(profile: &Profile) {
}

/// Delete a profile from the profiles directory
///
///
/// # Parameters
/// - `name` - the name of the profile to delete
///
///
/// # Returns
/// - `Result<()>`: whether the operation was successful
pub fn delete_profile(name: &str) -> Result<()> {
Expand All @@ -185,11 +184,11 @@ pub fn delete_profile(name: &str) -> Result<()> {
}

/// List all the stored profiles in the profiles directory
///
///
/// # Parameters
/// - `raw` - whether to list the profiles in raw format. If true, the profiles
/// will be listed without any decorations
///
///
/// # Returns
/// - `Result<()>`: whether the operation was successful
pub fn list_profiles(raw: bool) -> Result<()> {
Expand Down Expand Up @@ -242,11 +241,11 @@ pub fn list_profiles(raw: bool) -> Result<()> {
}

/// Download a profile from a URL and store it in the profiles directory
///
///
/// # Parameters
/// - `url` - the URL to download the profile from
/// - `profile_name` - the name of the profile to store the downloaded profile as
///
///
/// # Returns
/// - `Result<()>`: whether the operation was successful
pub fn download_profile(url: String, profile_name: String) -> Result<()> {
Expand Down Expand Up @@ -281,11 +280,11 @@ pub fn download_profile(url: String, profile_name: String) -> Result<()> {
}

/// Import a profile stored somewhere on the system but not in the profiles directory
///
///
/// # Parameters
/// - `file_path` - the path to the profile file
/// - `profile_name` - the name of the profile to store the imported profile as
///
///
/// # Returns
/// - `Result<()>`: whether the operation was successful
pub fn import_profile(file_path: String, profile_name: String) -> Result<()> {
Expand Down Expand Up @@ -392,10 +391,10 @@ fi
}

/// Load the environment variables of the profile into the current session
///
///
/// # Parameters
/// - `profile_name` - the name of the profile to load
///
///
/// # Returns
/// - `Result<()>`: whether the operation was successful
#[cfg(any(target_family = "unix"))]
Expand All @@ -420,7 +419,6 @@ pub fn load_profile(profile_name: &str) -> Result<()> {
Ok(())
}


/// Windows implementation of the load_profile function
#[cfg(target_family = "windows")]
pub fn load_profile(profile: Profile) {
Expand All @@ -436,7 +434,7 @@ pub fn load_profile(profile: Profile) {
}

/// Unload the environment variables of the profile from the current session
///
///
/// # Returns
/// - `Result<()>`: whether the operation was successful
#[cfg(any(target_family = "unix"))]
Expand Down
1 change: 0 additions & 1 deletion src/bin/envio/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// Implementation of all the subcommands that can be run by the CLI

use colored::Colorize;
use inquire::{min_length, Confirm, MultiSelect, Password, PasswordDisplayMode, Select, Text};
use regex::Regex;
Expand Down
14 changes: 7 additions & 7 deletions src/bin/envio/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use indicatif::{ProgressBar, ProgressStyle};
use reqwest::Client;

/// Get the home directory
///
///
/// # Returns
/// - `PathBuf`: the home directory
pub fn get_homedir() -> Result<PathBuf> {
Expand All @@ -22,7 +22,7 @@ pub fn get_homedir() -> Result<PathBuf> {
}

/// Get the config directory
///
///
/// # Returns
/// - `PathBuf`: the config directory
pub fn get_configdir() -> Result<PathBuf> {
Expand All @@ -37,11 +37,11 @@ pub fn get_cwd() -> PathBuf {
std::env::current_dir().unwrap()
}

/// Parse environment variables from a string
///
/// Parse environment variables from a string
///
/// # Parameters
/// - `buffer`: &str - the buffer to parse
///
///
/// # Returns
/// - `Result<HashMap<String, String>>`: the parsed environment variables
pub fn parse_envs_from_string(buffer: &str) -> Result<HashMap<String, String>> {
Expand Down Expand Up @@ -71,11 +71,11 @@ pub fn parse_envs_from_string(buffer: &str) -> Result<HashMap<String, String>> {
}

/// Download a file from a url with a progress bar
///
///
/// # Parameters
/// - `url`: &str - the url to download the file from
/// - `file_name`: &str - the name of the file to save the downloaded file to
///
///
/// # Returns
/// - `Result<()>`: an empty result
pub async fn download_file(url: &str, file_name: &str) -> Result<()> {
Expand Down
7 changes: 3 additions & 4 deletions src/bin/envio/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn get_cache_dir() -> Option<PathBuf> {
/// create the cache file If the cache file is older than 7 days, fetch the
/// latest version from GitHub API If the GitHub API fails, fetch the latest
/// version from git
///
///
/// # Returns
/// - `Version`: the latest version
pub fn get_latest_version() -> Version {
Expand Down Expand Up @@ -114,14 +114,13 @@ pub fn get_latest_version() -> Version {
}
}


/// Fetch the latest version from GitHub API or git If the GitHub API fails,
/// fetch the latest version from git If the git command fails, return the
/// fallback version
///
///
/// # Parameters
/// - `fallback_version`: &str - The fallback version
///
///
/// # Returns
/// - `Version`: The latest version
fn fetch_latest_version(fallback_version: &str) -> Version {
Expand Down
22 changes: 11 additions & 11 deletions src/crypto/gpg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,27 +156,27 @@ impl EncryptionType for GPG {
}

/// Get the GPG keys available on the system
///
/// There are two different implementations for Unix and Windows.
///
///
/// There are two different implementations for Unix and Windows.
///
/// The Unix implementation uses the gpgme crate to access the GPG keys on the
/// system. The Windows implementation uses the gpg command line tool to access
///
///
/// # Returns
/// - `Result<Vec<(String, String)>>`: Vec of tuples containing a formatted
/// string of the user id with the email and the key fingerprint
///
///
/// # Example
///
///
/// ```rust
/// use envio::crypto::get_gpg_keys;
///
/// use envio::crypto::gpg::get_gpg_keys;
///
/// let keys = get_gpg_keys().unwrap();
///
///
/// for key in keys {
/// println!("{}: {}", key.0, key.1);
/// }
///
///
/// ```
#[cfg(target_family = "unix")]
pub fn get_gpg_keys() -> Result<Vec<(String, String)>> {
Expand Down Expand Up @@ -290,7 +290,7 @@ pub fn get_gpg_keys() -> Option<Vec<(String, String)>> {
Some(available_keys)
}

/// Utility function to format the fingerprint.
/// Utility function to format the fingerprint.
/// Windows specific code
#[cfg(target_family = "windows")]
fn format_fingerprint<S: AsRef<str>>(fingerprint: S) -> String {
Expand Down
Loading

0 comments on commit cda0c54

Please sign in to comment.