From 4e9946f2fe64075f2f85a879f50d9e1edcf4355c Mon Sep 17 00:00:00 2001 From: Bon-Yong Lee Date: Wed, 5 Sep 2012 15:42:52 +0900 Subject: [PATCH] [Title] Add help detail for web-signing [Type] Enhancement [Module] Sub [Priority] Minor [CQ#] // CQ Issue Number [Redmine#] // Redmine Isuue Number [Problem] // Problem Description [Cause] // Cause Description [Solution] // Solution Description [TestCase] // Executed the test-target (How to) --- org.tizen.cli/doc/install/bin_/web-signing | 3 +- org.tizen.cli/doc/install/conf/profiles.xml | 5 ++ org.tizen.cli/doc/install/sample/profiles.xml | 4 +- .../install/sample/samsung.devmode.sdk.cert.p12 | Bin 0 -> 1781 bytes .../src/org/tizen/cli/exec/AbstractLauncher.java | 24 +++++++- org.tizen.cli/src/org/tizen/cli/exec/Help.java | 64 +++++++++++++++++++-- .../src/org/tizen/cli/exec/sign/Main.java | 17 ++++-- .../src/org/tizen/cli/exec/sign/profile.help | 1 + 8 files changed, 103 insertions(+), 15 deletions(-) create mode 100755 org.tizen.cli/doc/install/conf/profiles.xml create mode 100644 org.tizen.cli/doc/install/sample/samsung.devmode.sdk.cert.p12 diff --git a/org.tizen.cli/doc/install/bin_/web-signing b/org.tizen.cli/doc/install/bin_/web-signing index 0563925..2259bb4 100755 --- a/org.tizen.cli/doc/install/bin_/web-signing +++ b/org.tizen.cli/doc/install/bin_/web-signing @@ -31,6 +31,7 @@ CLASSPATH=$DIR_CONFIG:$JAR OPT_LOGGING="-Dlog4j.configuration=log4j.xml" OPT_PRG_NAME="-Dcli.name=$SCRIPT" +OPT_CLI_HOME="-Dcli.home=$DIR_HOME" READ_ARG="n" @@ -53,7 +54,7 @@ for WORD in $@; do esac done -OPT="$OPT_TRACE $OPT_LOGGING $OPT_PRG_NAME" +OPT="$OPT_TRACE $OPT_LOGGING $OPT_PRG_NAME $OPT_CLI_HOME" EXEC="java -cp $CLASSPATH $OPT $MAIN $@" diff --git a/org.tizen.cli/doc/install/conf/profiles.xml b/org.tizen.cli/doc/install/conf/profiles.xml new file mode 100755 index 0000000..032ea3d --- /dev/null +++ b/org.tizen.cli/doc/install/conf/profiles.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/org.tizen.cli/doc/install/sample/profiles.xml b/org.tizen.cli/doc/install/sample/profiles.xml index 7d352b7..82d93fe 100644 --- a/org.tizen.cli/doc/install/sample/profiles.xml +++ b/org.tizen.cli/doc/install/sample/profiles.xml @@ -1,7 +1,7 @@ - - + + diff --git a/org.tizen.cli/doc/install/sample/samsung.devmode.sdk.cert.p12 b/org.tizen.cli/doc/install/sample/samsung.devmode.sdk.cert.p12 new file mode 100644 index 0000000000000000000000000000000000000000..8302b60d49bacc03a4b0ed80d71de21092c82182 GIT binary patch literal 1781 zcmV9)K>yaPnn+75VIu4Ha;SM?Xbxi!k(jzsBFDOx*TpSZd|*{ZLYH7 zW9~+=+i`F`9YS{7z_+(1xcjR?E50u%p1qwF);V&9(Go)|kSbKC*qff&l$#kq$Bu%L zeI+)N$;2E=(9Rl!v zxQ?5|9g5-1_@IHR)hmyv$u4U^2GMRGr(HNg0f_p9Q}Koogo=jB|AFQTH^%X5qN3%K&GX&r!df>K zJl@(GPN)>$tgAYj7OFeW_x>NE{FU?&#PBf-cP_tqcQ_zhY6O5qp@DN7U!y}U##rDq zX?ik{`qUC-y*v1idw(?|<59TeZBie&&~?7f>gMfXvq{nSoQI5tc(`0JMOp;vzin?f zzu&Kn;&(|vPfh+LOOq^*EfCsWP{}oy&ORmlF54jUCu zSnIq~m*F#k8YRFT=h1U*Lsfqb?`R;>lPfsDjgx_i3!q9|FoFX41_>&LNQUd5#cv0o)IdgPJom9%MO(Hh z+Ky|*G5>|Qu}Nu}{a1MFY`-yM*(--Rg&6TvW5*ULOW;2hc=^zSb8V`9UpkW?N8g4= zzfc0%cjr0F9&pP0_hYmVh+tEGC-gZTOD#$AAh{0XXt9SMJAx_wxf6&5y@|EWxhNKOt7g0uY?C1^qw|g4QcUBKO3@%9@&R(Oi5gj8y{JeS!8bPwNm4HfjZioABxBnGHhK=PiU+e4Je;R{uHJ(4!gs zA3sSrE5K4VWN|NXvQ`2=^|YvK)~YSwRebj($|Kp?(}-exe7OE6bG59Qy4PK4(^->@ zG`bRc*&}DG2&)L?PT0)*73jW z8@ONf7&->}&Prq~WvCMVAx`{!tu#CB*$Yb$^2FjGnii#`-6n2EvtEIQSd>!8m;jux zg;|=ma2K!kuCNq}_eQH4#=!wz9Gh2zgHw8vFfw^upztN)9at>@8eR?kw%vx?<%1Ge_%Yp5nP&oqJ7pczL2Z z$XaNJbK0_hBHbY9B?Ro4n#dpDM8 zmAzA~4me2ZD(Pbb8wr62+wG8mHIX6lLf8Fb`KlgS{^KzvFe3&DDuzgg_YDCF6)_eB z6i3rFNzEU|-9LAX{1V06bTgLYwJ iter = cl.getResources( resourceName ); while ( iter.hasMoreElements() ) { final URL url = iter.nextElement(); + logger.trace( "URL :{}", url ); final Properties properties = PropertyUtil.loadProperties( url.openStream() ); + logger.debug( "Properties :{}", properties ); for ( final Object key : properties.keySet() ) { @@ -265,7 +271,9 @@ AbstractLauncher String printHelpDetail( String option ) { - return getHelp().getHelpDetail( option ); + final String detailStr = getHelp().getHelpDetail( option ); + getPrompter().error( detailStr ); + return detailStr; } /** @@ -277,7 +285,7 @@ AbstractLauncher String printHelp() { - String helpStr = getHelp().getHelp(); + final String helpStr = getHelp().getHelp(); getPrompter().error( helpStr ); return helpStr; } @@ -302,9 +310,9 @@ AbstractLauncher if ( logger.isTraceEnabled() ) { logger.trace( "System properties :\n{}", MapUtil.toString( System.getProperties() ) ); + logger.trace( "Args :{}", CollectionUtil.concatenate( Arrays.asList( args ), "," ) ); } - try { this.cmd = parse( args ); @@ -324,6 +332,8 @@ AbstractLauncher { printHelp(); + logger.debug( "Help argument :{}", cmd.getArgList() ); + for ( String keyword : cmd.getArgs() ) { printHelpDetail( keyword ); @@ -335,7 +345,15 @@ AbstractLauncher } catch ( final ParseException e ) { + logger.trace( "Invalid usage" ); printHelp(); + + logger.debug( "Help argument :{}", cmd.getArgList() ); + + for ( String keyword : cmd.getArgs() ) + { + printHelpDetail( keyword ); + } } catch ( final Exception e ) { diff --git a/org.tizen.cli/src/org/tizen/cli/exec/Help.java b/org.tizen.cli/src/org/tizen/cli/exec/Help.java index 16d5712..f47d309 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/Help.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/Help.java @@ -9,19 +9,43 @@ import java.util.HashMap; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Help { + + /** + * Logger for this instance + */ + protected Logger logger = LoggerFactory.getLogger( getClass() ); + /** * Program name property key */ protected static final String PROP_PRG = "cli.name"; + /** + * {@link Options} for Help print-out + */ protected final Options opts; + /** + *

+ * keyword - help mapping + *

+ */ protected HashMap keyword2help = new HashMap(); - public Help( Options opts ) + /** + * Constructor with {@link Options} + * + * @param opts {@link Options} + */ + public + Help( + final Options opts + ) { this.opts = opts; } @@ -38,13 +62,28 @@ public class Help return opts; } - public void addHelpDetail( String keyword, String help ) + /** + * Add help contents for keyword + * + * @param keyword keyword + * @param help contents + */ + public + void + addHelpDetail( + final String keyword, + final String help + ) { keyword2help.put( keyword.toLowerCase(), help ); + + logger.info( "Help Detail added for {} :\n{}", keyword, help ); } /** - * return execution command for usage + *

+ * Return execution command for usage + *

* * @return execution command */ @@ -54,6 +93,13 @@ public class Help } + /** + *

+ * Return default usage + *

+ * + * @return usage + */ public String getHelp() { final HelpFormatter formatter = new HelpFormatter(); @@ -79,8 +125,18 @@ public class Help return help; } + /** + *

+ * Return detail help for keyword + *

+ * + * @param keyword keyword + * @return detail + */ public String - getHelpDetail( final String keyword ) + getHelpDetail( + final String keyword + ) { if ( null == keyword ) { diff --git a/org.tizen.cli/src/org/tizen/cli/exec/sign/Main.java b/org.tizen.cli/src/org/tizen/cli/exec/sign/Main.java index 1b38000..456d42c 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/sign/Main.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/sign/Main.java @@ -25,7 +25,7 @@ package org.tizen.cli.exec.sign; import static org.tizen.common.util.FilenameUtil.addTailingPath; -import static org.tizen.common.util.StringUtil.nvl; +import static org.tizen.common.util.ObjectUtil.nvl; import java.io.IOException; import java.text.MessageFormat; @@ -34,6 +34,7 @@ import java.util.List; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; +import org.apache.commons.cli.ParseException; import org.tizen.cli.exec.AbstractLauncher; import org.tizen.cli.exec.ILaunchOptions; import org.tizen.common.core.command.Prompter; @@ -142,7 +143,7 @@ implements ILaunchOptions opts.addOption( OptionBuilder.hasArg().withLongOpt( OPT_INCLUDE ).withDescription( DESC_INCLUDE ).create( OPT_INCLUDE.substring( 0, 1 ) ) ); opts.addOption( OptionBuilder.hasArg().withLongOpt( OPT_EXCLUDE ).withDescription( DESC_EXCLUDE ).create( OPT_EXCLUDE.substring( 0, 1 ) ) ); - opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_PROFILE ).withDescription( DESC_PROFILE ).create( OPT_PROFILE.substring( 0, 1 ) ) ); + opts.addOption( OptionBuilder.hasArg().withLongOpt( OPT_PROFILE ).withDescription( DESC_PROFILE ).create( OPT_PROFILE.substring( 0, 1 ) ) ); return opts; } @@ -159,6 +160,14 @@ implements ILaunchOptions ) throws Exception { + + String profileName = cmdLine.getOptionValue( OPT_PROFILE ); + logger.debug( "Profile option :{}", profileName ); + if ( null == profileName ) + { + throw new ParseException( "profile option is requred" ); + } + final List args = cmdLine.getArgList(); logger.trace( "arguments :{}", args ); @@ -205,9 +214,6 @@ implements ILaunchOptions } } - String profileName = cmdLine.getOptionValue( OPT_PROFILE ); - logger.debug( "Profile option :{}", profileName ); - String profilesFilePath = null; final int index = profileName.indexOf( SEPARATOR_PROFILE ); @@ -258,6 +264,7 @@ implements ILaunchOptions String getDefaultProfilesFilePath() { + final String cliHome = nvl( System.getProperty( PROP_CLI_HOME ), System.getenv( ENV_CLI_HOME ) ); diff --git a/org.tizen.cli/src/org/tizen/cli/exec/sign/profile.help b/org.tizen.cli/src/org/tizen/cli/exec/sign/profile.help index 460a0d3..670b29f 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/sign/profile.help +++ b/org.tizen.cli/src/org/tizen/cli/exec/sign/profile.help @@ -8,6 +8,7 @@ Specify profile( profile name and profiles file path ) Ex.) web-signing -p develop:/home/tizen/profiles.xml + web-signing -p develop * profiles file format It is xml-formatted file. Its schema( xml schema ) exists in $CLI_HOME/doc/schema/profiles.xsd -- 2.7.4