Skip to content

Commit

Permalink
chore: cli design
Browse files Browse the repository at this point in the history
  • Loading branch information
atomotic committed Oct 23, 2023
1 parent 5c9e3b6 commit c2af39d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 44 deletions.
20 changes: 10 additions & 10 deletions cmd/run.go → cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

var Item string

var runCmd = &cobra.Command{
Use: "run",
var getCmd = &cobra.Command{
Use: "get",
Short: "download an item from Internet Archive and generate an IIIF manifest",
Long: `download an item from Internet Archive and generate an IIIF manifest`,
Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -22,18 +22,18 @@ var runCmd = &cobra.Command{
os.Exit(0)
}

Logo()
fmt.Printf("archiviiify\n\n")

item, err := internetarchive.New(Item)
if err != nil {
fmt.Println("metadata error")
}

fmt.Printf("· downloading %s\n", item.Metadata.Title)
fmt.Printf("· from %s\n", item.JP2Zip)
fmt.Printf("[1/3] Downloading %s:\n", item.Metadata.Title)
fmt.Printf(" Source: %s\n", item.JP2Zip)

if item.Downloaded() {
fmt.Println("already downloaded")
fmt.Println(" Item already downloaded")
} else {
err = item.Download()
if err != nil {
Expand All @@ -44,18 +44,18 @@ var runCmd = &cobra.Command{

time.Sleep(2 * time.Second)

fmt.Println("· generating IIIF manifest")
fmt.Println("[2/3] Generating IIIF manifest")
err = item.Manifest()
if err != nil {
fmt.Print(err)
os.Exit(0)
}
fmt.Printf("view http://localhost:9000/?manifest=%s\n", item.Metadata.Identifier)
fmt.Printf("[3/3] View the item:\n %s/?manifest=%s\n", os.Getenv("HOSTNAME"), item.Metadata.Identifier)

},
}

func init() {
rootCmd.AddCommand(runCmd)
runCmd.Flags().StringVarP(&Item, "identifier", "i", "", "IA item identifier")
rootCmd.AddCommand(getCmd)
getCmd.Flags().StringVarP(&Item, "identifier", "i", "", "IA item identifier")
}
16 changes: 0 additions & 16 deletions cmd/styles.go

This file was deleted.

5 changes: 0 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ go 1.21.0
require (
github.com/atomotic/iiif-presentation.go v0.0.0-20230327143406-f6a31ac83304
github.com/carlmjohnson/requests v0.23.5
github.com/charmbracelet/lipgloss v0.9.1
github.com/cheggaaa/pb v1.0.29
github.com/hashicorp/go-getter/v2 v2.2.1
github.com/joho/godotenv v1.5.1
github.com/spf13/cobra v1.7.0
)

require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
Expand All @@ -22,13 +20,10 @@ require (
github.com/hashicorp/go-version v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.11.2 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/go-homedir v1.0.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
Expand Down
12 changes: 0 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
github.com/atomotic/iiif-presentation.go v0.0.0-20230327143406-f6a31ac83304 h1:L2M81ZftyZ1CA4ChujFkK5VOkpy8t9iV2ZYP9iIYJwA=
github.com/atomotic/iiif-presentation.go v0.0.0-20230327143406-f6a31ac83304/go.mod h1:GzuC0P4sgZsDsbcjWWAWJefBw19VrcCNWS0CKKkHteI=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
github.com/carlmjohnson/requests v0.23.5 h1:NPANcAofwwSuC6SIMwlgmHry2V3pLrSqRiSBKYbNHHA=
github.com/carlmjohnson/requests v0.23.5/go.mod h1:zG9P28thdRnN61aD7iECFhH5iGGKX2jIjKQD9kqYH+o=
github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg=
github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I=
github.com/cheggaaa/pb v1.0.29 h1:FckUN5ngEk2LpvuG0fw1GEFx6LtyY2pWI/Z2QgCnEYo=
github.com/cheggaaa/pb v1.0.29/go.mod h1:W40334L7FMC5JKWldsTWbdGjLo0RxUKK73K+TuPxX30=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand All @@ -33,27 +29,19 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ=
github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down
3 changes: 2 additions & 1 deletion internetarchive/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ func (i *Item) Manifest() error {

counter := 1
for _, image := range jp2 {
api := fmt.Sprintf("http://localhost:9000/iiif/%s/%s/info.json",
api := fmt.Sprintf("%s/iiif/%s/%s/info.json",
os.Getenv("HOSTNAME"),
i.Metadata.Identifier,
path.Base(image))

Expand Down

0 comments on commit c2af39d

Please sign in to comment.