-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
6cdaa86
commit 6083006
Showing
9 changed files
with
73 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,35 @@ | ||
package defaults | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"io" | ||
|
||
"github.com/lucassabreu/clockify-cli/pkg/cmd/time-entry/util/defaults" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
const ( | ||
FORMAT_JSON = "json" | ||
FORMAT_YAML = "yaml" | ||
) | ||
|
||
type OutputFlags struct { | ||
Format string | ||
CSV bool | ||
JSON bool | ||
} | ||
|
||
// Report prints a DefaultTimeEntry using user's flags | ||
func Report(of OutputFlags, out io.Writer, v defaults.DefaultTimeEntry) error { | ||
var b []byte | ||
switch of.Format { | ||
case FORMAT_JSON: | ||
b, _ = json.Marshal(v) | ||
case FORMAT_YAML: | ||
b, _ = yaml.Marshal(v) | ||
default: | ||
return errors.New("invalid format") | ||
} | ||
|
||
_, err := out.Write(b) | ||
return err | ||
} |