Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Little cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MalteJanz committed Jun 30, 2024
1 parent a138573 commit cb1b5c5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fixed `--in-flight-limit` to actually be respected (wasn't implemented correctly)
- Changed default `in_flight_limit` to `8` (from `16`) as that seemed like a better performing number
- Implemented all criteria filter types and added `product_variants.yaml`
- Removed `sync --verbose` option for now, as it wasn't implemented

# v0.3.0
- Added `associations` entry for schema (used on export only)
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ to export data into (CSV) files or import data from (CSV) files.

- It's fast, with a focus on performance
- Every entity and field available in the API can be exported / imported
- Import / Export profiles are just `.yaml` files
- Supports data filtering and sorting using the API criteria
- Import / Export profiles (schema's) are just `.yaml` files
- Which can be copied + adapted + shared freely
- Profiles include a scripting engine for arbitrary data transformations
- For now only supports CSV files
Expand All @@ -23,15 +24,15 @@ to export data into (CSV) files or import data from (CSV) files.
```bash
cargo install sw-sync-cli
```
Same command can be used for updates.
Same command can be used for updates. See [crate](https://crates.io/crates/sw-sync-cli)

### Manual
head to [GitHub releases](https://github.com/MalteJanz/sw-sync-cli/releases) and download the right binary for your operating system.
Then either execute the binary directly or put it in your `PATH`.

## Usage

1. Setup an [integration](https://docs.shopware.com/en/shopware-6-en/settings/system/integrationen?category=shopware-6-en/settings/system) inside shopware.
1. Set up an [integration](https://docs.shopware.com/en/shopware-6-en/settings/system/integrationen?category=shopware-6-en/settings/system) inside shopware.
2. Call `sw-sync-cli auth` with the required arguments (credentials)

> [!Note]
Expand All @@ -40,10 +41,13 @@ Then either execute the binary directly or put it in your `PATH`.
3. Call `sw-sync-cli sync` in either `-m import` or `-m export` mode, with a profile (`schema.yaml`) and data file `data.csv`

### Profiles
> [!Info]
> You can call `sw-sync-cli help` at any time to get more information
### Profiles (sync schema)

To get started take a look at [Profiles in this repository](https://github.com/MalteJanz/sw-sync-cli/tree/main/profiles).
The structure of a profile `.yaml` is as follows:
The structure of a profile (sync schema) `.yaml` is as follows:

```yaml
entity: product
Expand Down Expand Up @@ -129,5 +133,4 @@ deserialize_script: |
linked: true,
currencyId: "b7d2554b0ce847cd82f3ac9bd1c0dfca",
});
```
16 changes: 6 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::api::SwClient;
use crate::config::{Credentials, Mapping, Schema};
use crate::data::{export, import, prepare_scripting_environment, ScriptingEnvironment};
use anyhow::Context;
use clap::{ArgAction, Parser, Subcommand};
use clap::{Parser, Subcommand};
use std::collections::HashSet;
use std::path::PathBuf;
use std::sync::Arc;
Expand Down Expand Up @@ -55,10 +55,9 @@ enum Commands {
#[arg(short, long)]
limit: Option<u64>,

/// Verbose output, used for debugging
#[arg(short, long, action = ArgAction::SetTrue)]
verbose: bool,

// Verbose output, used for debugging
// #[arg(short, long, action = ArgAction::SetTrue)]
// verbose: bool,
/// How many requests can be "in-flight" at the same time
#[arg(short, long, default_value = "8")]
in_flight_limit: usize,
Expand All @@ -78,7 +77,6 @@ pub struct SyncContext {
/// specifies the input or output file
pub file: PathBuf,
pub limit: Option<u64>,
pub verbose: bool,
pub scripting_environment: ScriptingEnvironment,
pub associations: HashSet<String>,
}
Expand All @@ -98,10 +96,10 @@ async fn main() -> anyhow::Result<()> {
schema,
file,
limit,
verbose,
// verbose,
in_flight_limit,
} => {
let context = create_context(schema, file, limit, verbose, in_flight_limit).await?;
let context = create_context(schema, file, limit, in_flight_limit).await?;

match mode {
SyncMode::Import => {
Expand Down Expand Up @@ -151,7 +149,6 @@ async fn create_context(
schema: PathBuf,
file: PathBuf,
limit: Option<u64>,
verbose: bool,
in_flight_limit: usize,
) -> anyhow::Result<SyncContext> {
let serialized_schema = tokio::fs::read_to_string(schema)
Expand Down Expand Up @@ -187,7 +184,6 @@ async fn create_context(
scripting_environment,
file,
limit,
verbose,
associations,
})
}

0 comments on commit cb1b5c5

Please sign in to comment.