-
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.
Merge pull request #62 from glotzerlab/complete
Shell autocomplete
- Loading branch information
Showing
13 changed files
with
735 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,55 @@ | ||
// Copyright (c) 2024 The Regents of the University of Michigan. | ||
// Part of row, released under the BSD 3-Clause License. | ||
|
||
use clap_complete::CompletionCandidate; | ||
use indicatif::{MultiProgress, ProgressDrawTarget}; | ||
|
||
use row::workflow::Workflow; | ||
use row::MultiProgressContainer; | ||
use row::{cluster, workspace}; | ||
|
||
/// List the actions in the current workflow. | ||
pub fn get_action_candidates() -> Vec<CompletionCandidate> { | ||
let Ok(workflow) = Workflow::open() else { | ||
return Vec::new(); | ||
}; | ||
|
||
workflow | ||
.action | ||
.into_iter() | ||
.map(|a| CompletionCandidate::new(a.name())) | ||
.collect() | ||
} | ||
|
||
/// List the clusters in the user's configuration | ||
pub fn get_cluster_candidates() -> Vec<CompletionCandidate> { | ||
let Ok(clusters) = cluster::Configuration::open() else { | ||
return Vec::new(); | ||
}; | ||
|
||
clusters | ||
.cluster | ||
.into_iter() | ||
.map(|a| CompletionCandidate::new(a.name)) | ||
.collect() | ||
} | ||
|
||
/// List the directories in the project's workspace | ||
pub fn get_directory_candidates() -> Vec<CompletionCandidate> { | ||
let multi_progress = MultiProgress::with_draw_target(ProgressDrawTarget::hidden()); | ||
let mut multi_progress_container = MultiProgressContainer::new(multi_progress.clone()); | ||
|
||
let Ok(workflow) = Workflow::open() else { | ||
return Vec::new(); | ||
}; | ||
|
||
let Ok(directories) = workspace::list_directories(&workflow, &mut multi_progress_container) | ||
else { | ||
return Vec::new(); | ||
}; | ||
|
||
directories | ||
.into_iter() | ||
.map(CompletionCandidate::new) | ||
.collect() | ||
} |
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
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
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