Giter Club home page Giter Club logo

Comments (9)

eyalbe4 avatar eyalbe4 commented on September 27, 2024

Hi @tartale,
You can already use jfrog-cli-go as a library and we would love to see it embedded in other applications. We made sure to keep the commands code separated from the CLI code, so that you can invoke the commands from your go application, the same way the CLI code does. Look at the cli.go files. You'll notice that only they are CLI related. Your code can invoke the commands the same way.

from jfrog-cli.

tartale avatar tartale commented on September 27, 2024

Thanks for the quick reply! I'm actually currently doing this, and found that, if you use the commands code as an entry point, it mostly works, with one exception - if the command you're calling experiences an error, the command doesn't return an error - it actually panics due to the assumption that the CLI library (codegansta) was initialized.

If you guys weren't interested in splitting the library out, another possibility would be to update to the latest of the codegansta/cli (moved to urfave/cli) allows the command function to return an error.

Here's an example of a code snippet that would cause a panic:

import (
    "github.com/jfrogdev/jfrog-cli-go/artifactory/commands"
    "github.com/jfrogdev/jfrog-cli-go/artifactory/utils"
    "github.com/jfrogdev/jfrog-cli-go/utils/config"
)

var ARTIFACTORY_CONF *config.ArtifactoryDetails = &config.ArtifactoryDetails{
    Url:      "http://website.com/artifactory", // notice the missing trailing /
    User:     "admin",
    Password: "foo",
}
downloadFlags := utils.Flags{
    ArtDetails:   ARTIFACTORY_CONF,
}
commands.Download("repo/*jre.rpm", &downloadFlags) 
// ^^ this panics, because I must either provide a trailing / for the Url
// or a preceding / for the specification.
// A returned error would be easier to work with

from jfrog-cli.

eyalbe4 avatar eyalbe4 commented on September 27, 2024

Thanks for pointing out this issue @tartale. We'll modify the commands API so that all commands return an error instead of throwing a panic. We'll let you know when done.

from jfrog-cli.

eyalbe4 avatar eyalbe4 commented on September 27, 2024

@tartale, just updating that we've already started working on modifying code, so that all APIs return an error, rather than exiting, when the packages is used as a library.

from jfrog-cli.

tartale avatar tartale commented on September 27, 2024

@eyalbe4 Great to hear - thank you!

from jfrog-cli.

eyalbe4 avatar eyalbe4 commented on September 27, 2024

@tartale, we pushed the code into the dev branch. It might still change a bit before the next release, but you can already look at it.

from jfrog-cli.

eyalbe4 avatar eyalbe4 commented on September 27, 2024

@tartale, JFrog CLI 1.5.0 includes this change. It does not exit when used as a library.

from jfrog-cli.

tartale avatar tartale commented on September 27, 2024

@eyalbe4 Thank you! I'll try it out

from jfrog-cli.

eyalbe4 avatar eyalbe4 commented on September 27, 2024

@tartale, I'm closing this issue for now. When you get a chance to use the APIs, we'd appreciate your feedback.

from jfrog-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.