Skip to content

Commit

Permalink
refactor(bin): rename to moccasin
Browse files Browse the repository at this point in the history
  • Loading branch information
rektdeckard committed Aug 30, 2023
1 parent 04e6fb4 commit 042c266
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/vhs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install tabss
- name: Install moccasin
run: cargo install --path .
- uses: charmbracelet/vhs-action@v1
with:
Expand Down
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
[package]
name = "tabss"
name = "moccasin"
version = "0.1.0"
edition = "2021"
authors = ["Tobias Fried <[email protected]>"]
license = "MIT"
description = "A tool to search files"
readme = "README.md"
homepage = "https://github.com/rektdeckard/moccasin"
repository = "https://github.com/rektdeckard/moccasin"
keywords = ["rss", "atom", "feed reader", "tui"]
categories = ["command-line-utilities"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
name = "mcsn"
path = "src/main.rs"

[dependencies]
anyhow = "1"
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# tabss
# moccasin

A TUI feed reader for RSS, Atom, and (aspirationally) Podcasts.
A TUI feed reader for RSS, Atom, and (eventually) Podcasts. This is not

![tabs TUI in action](https://github.com/rektdeckard/tabss/blob/main/meta/vhs.gif?raw=true)
[![NPM](https://img.shields.io/npm/v/deffo.svg?style=flat-square)](https://www.npmjs.com/package/deffo)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/deffo?style=flat-square)
![CI status](https://img.shields.io/github/actions/workflow/status/rektdeckard/moccasin/vhs.yaml?style=flat-square)

[![GitHub stars](https://img.shields.io/github/stars/rektdeckard/moccasin?style=flat-square&label=Star)](https://github.com/rektdeckard/moccasin)
[![GitHub forks](https://img.shields.io/github/forks/rektdeckard/moccasin?style=flat-square&label=Fork)](https://github.com/rektdeckard/moccasin/fork)
[![GitHub watchers](https://img.shields.io/github/watchers/rektdeckard/moccasin?style=flat-square&label=Watch)](https://github.com/rektdeckard/moccasin)
[![Follow on GitHub](https://img.shields.io/github/followers/rektdeckard?style=flat-square&label=Follow)](https://github.com/rektdeckard)

![tabs TUI in action](https://github.com/rektdeckard/moccasin/blob/main/meta/vhs.gif?raw=true)

## License

MIT © [Tobias Fried](https://github.com/rektdeckard)
15 changes: 10 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub type AppResult<T> = std::result::Result<T, Box<dyn error::Error>>;

#[derive(Debug)]
pub enum LoadState {
Loading((usize, usize)),
Loading(usize, usize),
Errored,
Done,
}
Expand Down Expand Up @@ -108,14 +108,19 @@ impl App {
match self.rx.poll_recv(&mut cx) {
Poll::Ready(m) => match m {
Some(StorageEvent::Requesting(amount)) => {
self.load_state = LoadState::Loading((0, amount));
self.load_state = match self.load_state {
LoadState::Loading(curr, total) => {
LoadState::Loading(curr, total + amount)
}
_ => LoadState::Loading(0, amount),
};
}
Some(StorageEvent::Fetched(counts)) => {
let counts = match self.load_state {
LoadState::Loading((current, total)) => (current + 1, total),
LoadState::Loading(current, total) => ((current + 1).min(total), total),
_ => counts,
};
self.load_state = LoadState::Loading(counts);
self.load_state = LoadState::Loading(counts.0, counts.1);
}
Some(StorageEvent::RetrievedAll(feeds)) => {
if self.config.should_cache() {
Expand Down Expand Up @@ -145,7 +150,7 @@ impl App {
}

match self.load_state {
LoadState::Loading(_) => {
LoadState::Loading(_, _) => {
self.load_state = LoadState::Done;
}
_ => {}
Expand Down
4 changes: 2 additions & 2 deletions src/config/tabss.toml → src/config/moccasin.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tabss config
# This file may be modified by tabss when changes are made via software,
# moccasin config
# This file may be modified by moccasin when changes are made via software,
# E.G. importing OPML files or individual feeds and changing colorschemes.

[sources]
Expand Down
8 changes: 4 additions & 4 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use toml_edit::{value, Document};

mod theme;

const DEFAULT_CONFIG_FILE: &'static str = "tabss.toml";
const DEFAULT_DB_FILE: &'static str = "tabss.db";
const DEFAULT_CONFIG_FILE: &'static str = "moccasin.toml";
const DEFAULT_DB_FILE: &'static str = "moccasin.db";
const DEFAULT_REFRESH_INTERVAL: u64 = 300;
const DEFAULT_REFRESH_TIMEOUT: u64 = 5;

Expand Down Expand Up @@ -86,7 +86,7 @@ impl Config {
let dir_path = file_path.parent().expect("could not find config directory");
(dir_path.into(), file_path.into())
} else {
let dir_path = ProjectDirs::from("com", "rektsoft", "tabss")
let dir_path = ProjectDirs::from("com", "rektsoft", "moccasin")
.unwrap()
.config_local_dir()
.to_owned();
Expand Down Expand Up @@ -260,7 +260,7 @@ impl Config {
fs::create_dir_all(&dir_path)?;
let cfg_path = Path::new(dir_path.as_path()).join(DEFAULT_CONFIG_FILE);
let mut file = File::create(&cfg_path)?;
let stub = include_str!("tabss.toml").parse::<Table>()?;
let stub = include_str!("moccasin.toml").parse::<Table>()?;
let feed_urls = stub["sources"]["feeds"]
.as_array()
.expect("parse default feeds")
Expand Down
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use clap::Parser;
use crossterm::terminal;
use moccasin::app::{App, AppResult, Args};
use moccasin::config::Config;
use moccasin::event::{Event, EventHandler};
use moccasin::handler::{handle_key_events, handle_mouse_events, handle_resize_events};
use moccasin::tui::Tui;
use std::io;
use tabss::app::{App, AppResult, Args};
use tabss::event::{Event, EventHandler};
use tabss::handler::{handle_key_events, handle_mouse_events, handle_resize_events};
use tabss::tui::Tui;
use tui::backend::CrosstermBackend;
use tui::Terminal;

Expand All @@ -14,7 +15,7 @@ async fn main() -> AppResult<()> {
let args = Args::parse();

// Read or create config
let config = tabss::config::Config::new(args)?;
let config = Config::new(args)?;

// Create an application.
let mut app = App::init(terminal::size().unwrap(), config).await?;
Expand All @@ -26,7 +27,6 @@ async fn main() -> AppResult<()> {
let mut tui = Tui::new(terminal, events);
tui.init()?;


// Start the main loop.
while app.running {
// Render the user interface.
Expand Down
6 changes: 3 additions & 3 deletions src/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Repository {
pub fn add_feed_by_url(&mut self, url: &str, config: &Config) {
let url = url.to_owned();
let app_tx = self.app_tx.clone();
let interval = config.refresh_interval();
let interval = config.refresh_timeout();

let _ = app_tx.send(StorageEvent::Requesting(1));

Expand Down Expand Up @@ -169,8 +169,8 @@ impl Repository {

tokio::spawn(async move {
let client = reqwest::Client::builder()
.connect_timeout(Duration::from_secs(config.refresh_interval()))
.timeout(Duration::from_secs(config.refresh_interval()))
.connect_timeout(Duration::from_secs(config.refresh_timeout()))
.timeout(Duration::from_secs(config.refresh_timeout()))
.build()
.expect("failed to build client");
let futures: Vec<_> = urls.into_iter().map(|url| client.get(url).send()).collect();
Expand Down
2 changes: 1 addition & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn render_status_bar<B: Backend>(app: &mut App, frame: &mut Frame<'_, B>, area:
.border_style(app.config.theme().active_border());

match app.load_state {
LoadState::Loading((n, count)) => {
LoadState::Loading(n, count) => {
if count > 0 {
frame.render_widget(
Gauge::default()
Expand Down
4 changes: 2 additions & 2 deletions vhs.tape
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Set Padding 32
Set Width 1600
Set Height 800

Type "tabss"
Type "mcsn"
Hide
Type " -c ./src/config/tabss.toml"
Type " -c ./src/config/moccasin.toml"
Sleep 1s
Enter
Show
Expand Down

0 comments on commit 042c266

Please sign in to comment.