Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
a-kenji committed Jul 20, 2024
1 parent f669a63 commit 4a23bd7
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 71 deletions.
1 change: 1 addition & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct IntermediaryTag {
name: String,
}

// TODO: actual error handling
pub fn get_tags(repo: &str, owner: &str) -> Result<Tags, ()> {
let tags = query_tags(repo, owner).unwrap();
Ok(tags.into())
Expand Down
11 changes: 1 addition & 10 deletions src/bin/flake-edit/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,19 @@ impl FlakeEdit {
pub fn root(&self) -> &FlakeBuf {
&self.root
}

pub fn run(&self) -> Result<(), FeError> {
Ok(())
}
}

#[derive(Debug, Default)]
pub struct FlakeBuf {
text: Rope,
path: String,
dirty: bool,
}

impl FlakeBuf {
fn from_path(path: PathBuf) -> io::Result<Self> {
let text = Rope::from_reader(&mut io::BufReader::new(File::open(&path)?))?;
let path = path.display().to_string();
Ok(Self {
text,
path,
dirty: false,
})
Ok(Self { text, path })
}

pub fn text(&self) -> &Rope {
Expand Down
3 changes: 0 additions & 3 deletions src/bin/flake-edit/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ impl From<String> for CompletionMode {
}
}

#[derive(Debug, Clone)]
pub(crate) enum Parameter {}

#[derive(Debug, Clone, Default)]
pub(crate) enum ListFormat {
None,
Expand Down
12 changes: 0 additions & 12 deletions src/bin/flake-edit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use flake_edit::change::Change;
use flake_edit::diff::Diff;
use flake_edit::edit;
use flake_edit::input::Follows;
use flake_edit::input::Input;
use flake_edit::update::Updater;
use nix_uri::urls::UrlWrapper;
use nix_uri::{FlakeRef, NixUriResult};
Expand Down Expand Up @@ -120,17 +119,6 @@ fn main() -> eyre::Result<()> {
std::process::exit(0);
}
},
Command::Add {
id,
uri,
ref_or_rev,
force,
no_flake,
} => todo!(),
Command::Pin { id } => todo!(),
Command::Change { id, uri } => todo!(),
Command::Remove { id } => todo!(),
Command::Completion { inputs, mode } => todo!(),
}

if let Ok(Some(resulting_change)) = editor.apply_change(change.clone()) {
Expand Down
23 changes: 0 additions & 23 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,6 @@ pub enum Follows {
Direct(String, Input),
}

impl Follows {}

#[derive(Debug, Default)]
pub(crate) struct FollowsBuilder {
attrs: Vec<String>,
}

impl FollowsBuilder {
pub(crate) fn push_str(&mut self, attr: &str) -> Option<Follows> {
self.attrs.push(attr.to_owned());
if self.attrs.len() == 4 {
Some(self.build())
} else {
None
}
}
fn build(&self) -> Follows {
let from = self.attrs.get(1).unwrap();
let to = self.attrs.get(3).unwrap();
Follows::Indirect(from.to_owned(), to.to_owned())
}
}

impl Default for Input {
fn default() -> Self {
Self {
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub mod diff;
pub mod edit;
pub mod error;
pub mod input;
mod semver;
pub mod state;
pub mod update;
pub mod walk;
11 changes: 0 additions & 11 deletions src/semver.rs

This file was deleted.

17 changes: 6 additions & 11 deletions src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ impl Updater {
}

pub fn change_input(&mut self, input: &UpdateInput) {
let change = input.update();
let uri = self
.text
.slice(
Expand All @@ -53,10 +52,12 @@ impl Updater {
let mut maybe_version = String::new();
let is_params = &parsed.params.get_ref().is_some();

if let nix_uri::FlakeRefType::GitHub { ref_or_rev, .. } = &parsed.r#type {
if let Some(ref_or_rev) = ref_or_rev {
maybe_version = ref_or_rev.into();
}
if let nix_uri::FlakeRefType::GitHub {
ref_or_rev: Some(ref_or_rev),
..
} = &parsed.r#type
{
maybe_version = ref_or_rev.into();
}
if let Some(r#ref) = &parsed.params.get_ref() {
maybe_version = r#ref.to_string();
Expand Down Expand Up @@ -147,9 +148,3 @@ impl PartialOrd for UpdateInput {
}

impl Eq for UpdateInput {}

impl UpdateInput {
fn update(&self) -> &str {
"1.3.4"
}
}
1 change: 1 addition & 0 deletions src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ impl<'a> Walker {
/// - description
/// - inputs
/// - outputs
#[allow(clippy::option_map_unit_fn)]
fn walk_toplevel(
&mut self,
node: SyntaxNode,
Expand Down

0 comments on commit 4a23bd7

Please sign in to comment.