| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- // This package defines several top level IO functions for interacting with
- // issues and collections of issues.
- //
- // Examples:
- //
- // To check if a folder is spec compliant:
- // ...
- // if issues.IsIssue(path_to_folder) {
- // process_issue(path_to_folder)
- // }
- //
- // Additionally, to check if a folder is a collection of spec compliant issues:
- // ...
- // if issues.IsIssueCollection(path_to_folder) {
- // process_collection(path_to_folder)
- // }
- //
- // To write an [Issue] object to disk:
- // ...
- // // NOT IMPLEMENTED
- //
- // To remove an [Issue] object from disk:
- // ...
- // // NOT IMPLEMENTED
- package issues
- import (
- "os"
- )
- func readPath(path string) (output string, err error) {
- content, err := os.ReadFile(path)
- if err != nil {
- return "", err
- }
- for _, line := range content {
- output = output + string(line)
- }
- return output, nil
- }
- // Reports true when the specified path conforms to the minimum Poorman spec
- func IsIssue(path string) bool {
- files, err := os.ReadDir(path)
- if err != nil {
- return false
- }
- var specFiles []bool
- for _, file := range files {
- if file.Name() == "description" || file.Name() == "status" {
- specFiles = append(specFiles, true)
- }
- }
- if len(specFiles) >= 2 {
- return true
- }
- return false
- }
- // Reports true when the specified path is a directory of Issues
- func IsIssueCollection(path string) bool {
- if IsIssue(path) {
- return false
- }
- files, err := os.ReadDir(path)
- if err != nil {
- return false
- }
- var isIssue []bool
- for _, file := range files {
- if IsIssue(path + "/" + file.Name()) {
- isIssue = append(isIssue, true)
- }
- }
- if len(isIssue) > 0 {
- return true
- }
- return false
- }
- // Writes a issue to disk
- func WriteIssue(issue Issue) (success bool, err error) { return false, nil } // TODO: implement
- // Removes a issue from disk
- func DeleteIssue(issue Issue) (success bool, err error) { return false, nil } // TODO: implement
|