Compare commits
2 Commits
4ebfb08d2e
...
51971d0202
Author | SHA1 | Date | |
---|---|---|---|
|
51971d0202 | ||
e2be9ba59a |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
target/
|
target/
|
||||||
.cuddle/
|
.cuddle/
|
||||||
|
.DS_Store
|
||||||
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [0.2.1] - 2024-09-22
|
## [0.2.1] - 2024-09-22
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
- include vhs demo
|
||||||
- add interactive search
|
- add interactive search
|
||||||
- implement naive fuzzy matcher
|
- implement naive fuzzy matcher
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
Git Now is a utility for easily navigating git projects from common upstream providers. Search, Download, and Enter projects as quickly as you can type.
|
Git Now is a utility for easily navigating git projects from common upstream providers. Search, Download, and Enter projects as quickly as you can type.
|
||||||
|
|
||||||
|
![example gif](./assets/gifs/example.gif)
|
||||||
|
|
||||||
How many steps do you normally do to download a project?
|
How many steps do you normally do to download a project?
|
||||||
|
|
||||||
1. Navigate to github.com
|
1. Navigate to github.com
|
||||||
|
BIN
assets/gifs/example.gif
Normal file
BIN
assets/gifs/example.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 643 KiB |
@ -29,3 +29,6 @@ ratatui = "0.28.1"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "1.4.0"
|
pretty_assertions = "1.4.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
example = []
|
||||||
|
@ -19,10 +19,15 @@ impl RootCommand {
|
|||||||
Self { app }
|
Self { app }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute(&mut self, search: Option<impl Into<String>>) -> anyhow::Result<()> {
|
pub async fn execute(
|
||||||
|
&mut self,
|
||||||
|
search: Option<impl Into<String>>,
|
||||||
|
cache: bool,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
tracing::debug!("executing");
|
tracing::debug!("executing");
|
||||||
|
|
||||||
let repositories = match self.app.cache().get().await? {
|
let repositories = if cache {
|
||||||
|
match self.app.cache().get().await? {
|
||||||
Some(repos) => repos,
|
Some(repos) => repos,
|
||||||
None => {
|
None => {
|
||||||
tracing::info!("finding repositories...");
|
tracing::info!("finding repositories...");
|
||||||
@ -32,6 +37,9 @@ impl RootCommand {
|
|||||||
|
|
||||||
repositories
|
repositories
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.app.projects_list().get_projects().await?
|
||||||
};
|
};
|
||||||
match search {
|
match search {
|
||||||
Some(needle) => {
|
Some(needle) => {
|
||||||
|
@ -25,6 +25,9 @@ struct Command {
|
|||||||
|
|
||||||
#[arg()]
|
#[arg()]
|
||||||
search: Option<String>,
|
search: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long = "no-cache", default_value = "false")]
|
||||||
|
no_cache: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
@ -56,7 +59,9 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
match cli.command {
|
match cli.command {
|
||||||
Some(_) => todo!(),
|
Some(_) => todo!(),
|
||||||
None => {
|
None => {
|
||||||
RootCommand::new(app).execute(cli.search.as_ref()).await?;
|
RootCommand::new(app)
|
||||||
|
.execute(cli.search.as_ref(), !cli.no_cache)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,34 @@
|
|||||||
use crate::{
|
#[cfg(not(feature = "example"))]
|
||||||
|
pub use implementation::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "example")]
|
||||||
|
pub use example_projects::*;
|
||||||
|
|
||||||
|
use crate::app::App;
|
||||||
|
|
||||||
|
pub trait ProjectsListApp {
|
||||||
|
fn projects_list(&self) -> ProjectsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProjectsListApp for &'static App {
|
||||||
|
fn projects_list(&self) -> ProjectsList {
|
||||||
|
ProjectsList::new(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod implementation {
|
||||||
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
git_provider::{
|
git_provider::{
|
||||||
gitea::GiteaProviderApp, github::GitHubProviderApp, Repository, VecRepositoryExt,
|
gitea::GiteaProviderApp, github::GitHubProviderApp, Repository, VecRepositoryExt,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ProjectsList {
|
pub struct ProjectsList {
|
||||||
app: &'static App,
|
app: &'static App,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProjectsList {
|
impl ProjectsList {
|
||||||
pub fn new(app: &'static App) -> Self {
|
pub fn new(app: &'static App) -> Self {
|
||||||
Self { app }
|
Self { app }
|
||||||
}
|
}
|
||||||
@ -73,7 +92,10 @@ impl ProjectsList {
|
|||||||
for github in self.app.config.providers.github.iter() {
|
for github in self.app.config.providers.github.iter() {
|
||||||
if let Some(_user) = &github.current_user {
|
if let Some(_user) = &github.current_user {
|
||||||
let mut repos = github_provider
|
let mut repos = github_provider
|
||||||
.list_repositories_for_current_user(github.url.as_ref(), &github.access_token)
|
.list_repositories_for_current_user(
|
||||||
|
github.url.as_ref(),
|
||||||
|
&github.access_token,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
repositories.append(&mut repos);
|
repositories.append(&mut repos);
|
||||||
@ -106,14 +128,8 @@ impl ProjectsList {
|
|||||||
|
|
||||||
Ok(repositories)
|
Ok(repositories)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ProjectsListApp {
|
|
||||||
fn projects_list(&self) -> ProjectsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ProjectsListApp for &'static App {
|
|
||||||
fn projects_list(&self) -> ProjectsList {
|
|
||||||
ProjectsList::new(self)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "example")]
|
||||||
|
mod example_projects;
|
||||||
|
84
crates/gitnow/src/projects_list/example_projects.rs
Normal file
84
crates/gitnow/src/projects_list/example_projects.rs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
use crate::{app::App, git_provider::Repository};
|
||||||
|
|
||||||
|
pub struct ProjectsList {}
|
||||||
|
|
||||||
|
impl ProjectsList {
|
||||||
|
pub fn new(_app: &'static App) -> Self {
|
||||||
|
Self {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_projects(&self) -> anyhow::Result<Vec<Repository>> {
|
||||||
|
Ok(self.from_strings([
|
||||||
|
"github.com/kjuulh/gitnow",
|
||||||
|
"github.com/kjuulh/gitnow-client",
|
||||||
|
"github.com/kjuulh/crunch",
|
||||||
|
"git.front.kjuulh.io/kjuulh/gitnow",
|
||||||
|
"git.front.kjuulh.io/kjuulh/gitnow-client",
|
||||||
|
"git.front.kjuulh.io/kjuulh/cuddle",
|
||||||
|
"git.front.kjuulh.io/kjuulh/buckle",
|
||||||
|
"git.front.kjuulh.io/kjuulh/books",
|
||||||
|
"git.front.kjuulh.io/kjuulh/blog-deployment",
|
||||||
|
"git.front.kjuulh.io/kjuulh/blog",
|
||||||
|
"git.front.kjuulh.io/kjuulh/bitfield",
|
||||||
|
"git.front.kjuulh.io/kjuulh/bitebuds-deployment",
|
||||||
|
"git.front.kjuulh.io/kjuulh/bitebuds",
|
||||||
|
"git.front.kjuulh.io/kjuulh/beerday",
|
||||||
|
"git.front.kjuulh.io/kjuulh/bearing",
|
||||||
|
"git.front.kjuulh.io/kjuulh/basic-webserver",
|
||||||
|
"git.front.kjuulh.io/kjuulh/backup",
|
||||||
|
"git.front.kjuulh.io/kjuulh/backstage",
|
||||||
|
"git.front.kjuulh.io/kjuulh/autom8-calendar-integration",
|
||||||
|
"git.front.kjuulh.io/kjuulh/astronvim",
|
||||||
|
"git.front.kjuulh.io/kjuulh/artifacts",
|
||||||
|
"git.front.kjuulh.io/kjuulh/articles",
|
||||||
|
"git.front.kjuulh.io/kjuulh/acc-server",
|
||||||
|
"git.front.kjuulh.io/kjuulh/_cargo-index",
|
||||||
|
"git.front.kjuulh.io/keep-up/keep-up-example",
|
||||||
|
"git.front.kjuulh.io/keep-up/keep-up",
|
||||||
|
"git.front.kjuulh.io/experiments/wasm-bin",
|
||||||
|
"git.front.kjuulh.io/dotfiles/doom",
|
||||||
|
"git.front.kjuulh.io/danskebank/testssl.sh",
|
||||||
|
"git.front.kjuulh.io/clank/kubernetes-state",
|
||||||
|
"git.front.kjuulh.io/clank/kubernetes-init",
|
||||||
|
"git.front.kjuulh.io/clank/blog",
|
||||||
|
"git.front.kjuulh.io/cibus/deployments",
|
||||||
|
"git.front.kjuulh.io/butikkaerlighilsen/client",
|
||||||
|
"git.front.kjuulh.io/bevy/bevy",
|
||||||
|
"git.front.kjuulh.io/OpenFood/openfood",
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_strings(
|
||||||
|
&self,
|
||||||
|
repos_into: impl IntoIterator<Item = impl Into<Repository>>,
|
||||||
|
) -> Vec<Repository> {
|
||||||
|
let repos = repos_into
|
||||||
|
.into_iter()
|
||||||
|
.map(|item| item.into())
|
||||||
|
.collect::<Vec<Repository>>();
|
||||||
|
|
||||||
|
repos
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&str> for Repository {
|
||||||
|
fn from(value: &str) -> Self {
|
||||||
|
let values = value.split("/").collect::<Vec<_>>();
|
||||||
|
if values.len() != 3 {
|
||||||
|
panic!("value: '{value}' isn't a valid provider/owner/repository")
|
||||||
|
}
|
||||||
|
|
||||||
|
let (provider, owner, name) = (
|
||||||
|
values.get(0).unwrap(),
|
||||||
|
values.get(1).unwrap(),
|
||||||
|
values.get(2).unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
|
Self {
|
||||||
|
provider: provider.to_string(),
|
||||||
|
owner: owner.to_string(),
|
||||||
|
repo_name: name.to_string(),
|
||||||
|
ssh_url: format!("ssh://git@{provider}/{owner}/{name}.git"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,3 +15,9 @@ please:
|
|||||||
api_url: "https://git.front.kjuulh.io"
|
api_url: "https://git.front.kjuulh.io"
|
||||||
actions:
|
actions:
|
||||||
rust:
|
rust:
|
||||||
|
|
||||||
|
scripts:
|
||||||
|
record:
|
||||||
|
type: shell
|
||||||
|
update-gifs:
|
||||||
|
type: shell
|
||||||
|
13
scripts/record.sh
Executable file
13
scripts/record.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Loop through each file in the folder
|
||||||
|
for file in "vhs"/*; do
|
||||||
|
# Check if it is a file (not a directory)
|
||||||
|
if [[ -f "$file" ]]; then
|
||||||
|
echo "Recording: $file"
|
||||||
|
|
||||||
|
vhs "./$file"
|
||||||
|
fi
|
||||||
|
done
|
9
scripts/update-gifs.sh
Executable file
9
scripts/update-gifs.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
rm -r assets/gifs
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cuddle x record
|
||||||
|
mkdir -p assets/gifs
|
||||||
|
mv target/vhs/* assets/gifs
|
14
vhs/example.vhs
Normal file
14
vhs/example.vhs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Output "target/vhs/example.gif"
|
||||||
|
Set Theme "Aardvark Blue"
|
||||||
|
Set Width 1200
|
||||||
|
Set Height 1000
|
||||||
|
Hide
|
||||||
|
Type "cargo run --features example -- --no-cache"
|
||||||
|
Enter
|
||||||
|
Sleep 1s
|
||||||
|
Show
|
||||||
|
Sleep 2s
|
||||||
|
Type@500ms "bevy"
|
||||||
|
Sleep 3s
|
||||||
|
Enter
|
||||||
|
Sleep 3s
|
Loading…
Reference in New Issue
Block a user