update docs & Cargo.toml

This commit is contained in:
qwjyh 2024-03-17 03:25:44 +09:00
parent 0e8bd6b4c7
commit f5fe3d6580
12 changed files with 50 additions and 32 deletions

View file

@ -1,7 +1,12 @@
[package]
name = "xdbm"
version = "0.1.0"
authors = ["qwjyh <urataw421@gmail.com>"]
edition = "2021"
description = "Cross device backup manager, to manage backups on several storages mounted on multiple devices."
homepage = "https://github.com/qwjyh/xdbm"
repository = "https://github.com/qwjyh/xdbm"
license = "MIT OR Apache-1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,4 +1,15 @@
# TODO:
# xdbm
_Cross device backup manager_,
to manage backups on several storages mounted on multiple devices with a single repository.
## Usage
1. `xdbm init` to setup new device(i.e. PC).
2. `xdbm storage add` to add storages, or `xdbm storage bind` to make existing storages available on new device.
3. `xdbm backup add` to add new backup configuration.
4. `xdbm backup done` to tell xdbm to write backup execution datetime.
5. `xdbm storage list` and `xdbm backup list` to see their status.
## TODO:
- [x] split subcommands to functions
- [x] write test for init subcommand
- [x] write test with existing repo

View file

@ -1,3 +1,6 @@
//! Backup config and its history.
//!
use core::panic;
use std::{
collections::HashMap,
@ -11,7 +14,7 @@ use serde::{Deserialize, Serialize};
use crate::{
devices::Device,
storages::{self, Storage, StorageExt, Storages},
storages::{StorageExt, Storages},
};
/// Directory to store backup configs for each devices.
@ -26,7 +29,7 @@ pub fn backups_file(device: &Device) -> PathBuf {
/// Targets for backup source or destination.
#[derive(Debug, Serialize, Deserialize)]
pub struct BackupTarget {
/// `name()` of [`Storage`].
/// `name()` of [`crate::storages::Storage`].
/// Use `String` for serialization/deserialization.
pub storage: String,
/// Relative path to the `storage`.

View file

@ -1,7 +1,7 @@
use std::{
collections::HashMap,
io::{self, stdout, Write},
path::{self, PathBuf},
path::{ PathBuf},
};
use anyhow::{anyhow, Context, Ok, Result};

View file

@ -1,7 +1,7 @@
//! Init subcommand.
//! Initialize xdbm for the device.
use crate::backups::{backups_file, Backups};
use crate::backups::Backups;
use crate::storages::{Storages, STORAGESFILE};
use crate::{
add_and_commit, backups, full_status, get_devices, write_devices, Device, DEVICESFILE,

View file

@ -14,13 +14,12 @@ use unicode_width::{self, UnicodeWidthStr};
use crate::{
add_and_commit,
cmd_args::{Cli, StorageAddCommands},
cmd_args::StorageAddCommands,
devices::{self, Device},
inquire_filepath_completer::FilePathCompleter,
storages::{
self, directory, local_info,
physical_drive_partition::{self, PhysicalDrivePartition},
Storage, StorageExt, StorageType, Storages,
Storage, StorageExt, Storages,
},
util,
};

View file

@ -1,29 +1,28 @@
//! # Main types
//! * [Device]: represents PC. module [devices]
//! * [Storage]: all storages. module [storages]
//! * [physical_drive_partition::PhysicalDrivePartition]: partition on a physical disk. module [storages::physical_drive_partition]
//! * [directory::Directory]: sub-directory of other storages. module [storages::directory]
//! * [online_storage::OnlineStorage]: online storage like Google Drive. module [storages::online_storage]
//! * [storages::local_info::LocalInfo]: stores [Device] specific common data for [Storage]s.
//!
//! * [storages::Storage]: all storages. module [storages]
//! * [storages::physical_drive_partition::PhysicalDrivePartition]: partition on a physical disk. module [storages::physical_drive_partition]
//! * [storages::directory::Directory]: sub-directory of other storages. module [storages::directory]
//! * [storages::online_storage::OnlineStorage]: online storage like Google Drive. module [storages::online_storage]
//! * [storages::Storages] for list of [storages::Storage]
//! * [storages::local_info::LocalInfo]: stores [Device] specific common data for [storages::Storage]s.
//! * [backups::Backup] for backup configuration and its logs.
//! * [backups::BackupTarget] source and destination
//! * [backups::BackupLog] backup log
#[macro_use]
extern crate log;
extern crate dirs;
use anyhow::{anyhow, Context, Result};
use clap::{CommandFactory, Parser};
use anyhow::{Context, Result};
use clap::Parser;
use git2::{Commit, Oid, Repository};
use std::path::Path;
use std::path::{self, PathBuf};
use storages::Storages;
use crate::cmd_args::{BackupSubCommands, Cli, Commands, StorageCommands};
use crate::storages::{
directory, local_info, online_storage, physical_drive_partition, Storage, StorageExt,
StorageType, STORAGESFILE,
};
use devices::{Device, DEVICESFILE, *};
mod backups;

View file

@ -1,9 +1,10 @@
//! Manipulates storages.
use crate::storages::directory::Directory;
use crate::storages::online_storage::OnlineStorage;
use crate::storages::physical_drive_partition::PhysicalDrivePartition;
use crate::{devices, storages};
use crate::devices;
use crate::storages::{
directory::Directory, online_storage::OnlineStorage,
physical_drive_partition::PhysicalDrivePartition,
};
use anyhow::{anyhow, Context, Result};
use clap::ValueEnum;
use core::panic;

View file

@ -1,7 +1,7 @@
//! Device specific common data for storages.
use serde::{Deserialize, Serialize};
use std::path::{self, PathBuf};
use std::path::PathBuf;
/// Store local (device-specific) information
///
@ -10,11 +10,11 @@ use std::path::{self, PathBuf};
#[derive(Serialize, Deserialize, Debug)]
pub struct LocalInfo {
alias: String,
mount_path: path::PathBuf,
mount_path: PathBuf,
}
impl LocalInfo {
pub fn new(alias: String, mount_path: path::PathBuf) -> LocalInfo {
pub fn new(alias: String, mount_path: PathBuf) -> LocalInfo {
LocalInfo { alias, mount_path }
}
@ -22,7 +22,7 @@ impl LocalInfo {
self.alias.clone() // ?
}
pub fn mount_path(&self) -> path::PathBuf {
pub fn mount_path(&self) -> PathBuf {
self.mount_path.clone()
}
}

View file

@ -87,7 +87,7 @@ impl StorageExt for OnlineStorage {
Ok(())
}
fn parent(&self, storages: &Storages) -> Option<&Storage> {
fn parent(&self, _storages: &Storages) -> Option<&Storage> {
None
}
}

View file

@ -165,7 +165,7 @@ impl StorageExt for PhysicalDrivePartition {
Ok(())
}
fn parent(&self, storages: &Storages) -> Option<&Storage> {
fn parent(&self, _storages: &Storages) -> Option<&Storage> {
None
}
}

View file

@ -1,8 +1,8 @@
mod cmd_init {
use std::fs::DirBuilder;
use anyhow::{anyhow, Ok, Result};
use assert_cmd::{assert::OutputAssertExt, cargo::CommandCargoExt, Command};
use anyhow::{Ok, Result};
use assert_cmd::{assert::OutputAssertExt, Command};
use git2::Repository;
use log::trace;
use predicates::prelude::predicate;