Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
gitplm
dist
gitplm.yaml
gitplm.yml
.gitplm.yaml
.gitplm.yml
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@ For more details or to discuss releases, please visit the

## [Unreleased]

### Added

- Interactive TUI (Terminal User Interface) mode when no command line arguments
are provided
- TUI prompt for configuring partmaster directory when not set in configuration
- Automatic saving of partmaster directory configuration to `gitplm.yml`
- Scrollable table display of partmaster data in TUI with columns: IPN,
Description, Manufacturer, MPN, Value
- Enhanced file search pattern supporting `CCC-NNN-VV.csv` and `CCC-NNN-VV.yml`
formats
- YAML configuration file support (`gitplm.yaml`, `gitplm.yml`, `.gitplm.yaml`,
`.gitplm.yml`)
- Start of KiCad HTTP library API support

### Enhanced

- Source file discovery now supports variation-based file naming using first two
digits of variation number
- File search priority: base pattern (`CCC-NNN.csv`) first, then variation
pattern (`CCC-NNN-VV.csv`)
- Improved user experience with seamless configuration flow in TUI mode
- Quantity fields now support fractional values (e.g., 0.5, 1.25) for more
precise BOM specifications

## [[0.6.0] - 2024-02-02](https://github.com/git-plm/gitplm/releases/tag/v0.6.0)

- add `-pmDir` command line parameter to specify parts database directory
Expand All @@ -21,6 +45,7 @@ For more details or to discuss releases, please visit the
';'. It turns out that anything besides ',' introduces a lot of friction in
using other tools like LibreOffice.
- breaking change: switch to using space for reference delimiters (was ',')
- improve error handling

## [[0.4.0] - 2024-02-02](https://github.com/git-plm/gitplm/releases/tag/v0.4.0)

Expand Down
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ Usage of gitplm:
display version of this application
```

## Configuration

GitPLM supports configuration via YAML files. The tool will look for configuration files in the following order:

1. Current directory: `gitplm.yaml`, `gitplm.yml`, `.gitplm.yaml`, `.gitplm.yml`
2. Home directory: `~/.gitplm.yaml`, `~/.gitplm.yml`

Example configuration file:

```yaml
pmDir: /path/to/partmaster/directory
```

Available configuration options:

- `pmDir`: Specifies the directory containing the partmaster.csv file

## Part Numbers

Each part used to make a product is defined by a
Expand Down Expand Up @@ -129,10 +146,22 @@ hierarchy of release directories for the entire product.
For parts you produce, GitPLM scans the directory tree looking for source
directories which are identified by one or both of the following files:

- an input BOM. Ex: `ASY-023.csv`
- a release configuration file. Ex: `PCB-019.yml`
- an input BOM. Ex: `ASY-023.csv` or `ASY-023-01.csv`
- a release configuration file. Ex: `PCB-019.yml` or `PCB-019-02.yml`

GitPLM supports two file naming patterns for source files:

1. **Base pattern**: `CCC-NNN.csv` and `CCC-NNN.yml` (e.g., `PCB-019.csv`, `ASY-023.yml`)
2. **Variation pattern**: `CCC-NNN-VV.csv` and `CCC-NNN-VV.yml` (e.g., `PCB-019-01.csv`, `ASY-023-02.yml`)

The variation pattern uses the first two digits of the variation number, allowing you to organize files by variation ranges. For example:
- `PCB-019-00.csv` for variations 0000-0099
- `PCB-019-01.csv` for variations 0100-0199
- `PCB-019-02.csv` for variations 0200-0299

When processing a release, GitPLM first searches for the base pattern, then falls back to the variation pattern if the base pattern is not found.

If either of these is found, GitPLM considers this a source directory and will
If either of these files is found, GitPLM considers this a source directory and will
use this directory to generate release directories.

A source directory might contain:
Expand Down
30 changes: 15 additions & 15 deletions bom.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import (
)

type bomLine struct {
IPN ipn `csv:"IPN" yaml:"ipn"`
Qty int `csv:"Qty" yaml:"qty"`
MPN string `csv:"MPN" yaml:"mpn"`
Manufacturer string `csv:"Manufacturer" yaml:"manufacturer"`
Ref string `csv:"Ref" yaml:"ref"`
Value string `csv:"Value" yaml:"value"`
CmpName string `csv:"Cmp name" yaml:"cmpName"`
Footprint string `csv:"Footprint" yaml:"footprint"`
Description string `csv:"Description" yaml:"description"`
Vendor string `csv:"Vendor" yaml:"vendor"`
Datasheet string `csv:"Datasheet" yaml:"datasheet"`
Checked string `csv:"Checked" yaml:"checked"`
IPN ipn `csv:"IPN" yaml:"ipn"`
Qty float64 `csv:"Qty" yaml:"qty"`
MPN string `csv:"MPN" yaml:"mpn"`
Manufacturer string `csv:"Manufacturer" yaml:"manufacturer"`
Ref string `csv:"Ref" yaml:"ref"`
Value string `csv:"Value" yaml:"value"`
CmpName string `csv:"Cmp name" yaml:"cmpName"`
Footprint string `csv:"Footprint" yaml:"footprint"`
Description string `csv:"Description" yaml:"description"`
Vendor string `csv:"Vendor" yaml:"vendor"`
Datasheet string `csv:"Datasheet" yaml:"datasheet"`
Checked string `csv:"Checked" yaml:"checked"`
}

func (bl *bomLine) String() string {
Expand Down Expand Up @@ -50,7 +50,7 @@ func (bl *bomLine) removeRef(ref string) {
}
}
bl.Ref = strings.Join(refsOut, " ")
bl.Qty = len(refsOut)
bl.Qty = float64(len(refsOut))
}

func sortReferenceDesignators(input string) string {
Expand Down Expand Up @@ -132,7 +132,7 @@ func (b *bom) copy() bom {
return ret
}

func (b *bom) processOurIPN(pn ipn, qty int) error {
func (b *bom) processOurIPN(pn ipn, qty float64) error {
log.Println("processing our IPN: ", pn, qty)

// check if BOM exists
Expand Down Expand Up @@ -180,7 +180,7 @@ func (b *bom) addItem(newItem *bomLine) {

func (b *bom) addItemMPN(newItem *bomLine, includeRef bool) {
if newItem.Qty <= 0 {
newItem.Qty = 1
newItem.Qty = 1.0
}

for i, l := range *b {
Expand Down
68 changes: 68 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package main

import (
"os"
"path/filepath"

"gopkg.in/yaml.v2"
)

type Config struct {
PMDir string `yaml:"pmDir"`
}

func loadConfig() (*Config, error) {
config := &Config{}

// Look for config file in current directory first, then home directory
configPaths := []string{
"gitplm.yaml",
"gitplm.yml",
".gitplm.yaml",
".gitplm.yml",
}

// Also check home directory
if homeDir, err := os.UserHomeDir(); err == nil {
homePaths := []string{
filepath.Join(homeDir, ".gitplm.yaml"),
filepath.Join(homeDir, ".gitplm.yml"),
}
configPaths = append(configPaths, homePaths...)
}

var configData []byte
var err error

// Try to find and load a config file
for _, path := range configPaths {
if configData, err = os.ReadFile(path); err == nil {
break
}
}

// If no config file found, return empty config (not an error)
if err != nil {
return config, nil
}

err = yaml.Unmarshal(configData, config)
if err != nil {
return nil, err
}

return config, nil
}

func saveConfig(pmDir string) error {
config := Config{
PMDir: pmDir,
}

data, err := yaml.Marshal(&config)
if err != nil {
return err
}

return os.WriteFile("gitplm.yml", data, 0644)
}
Loading
Loading